2020-05-04 07:53:47 -05:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
2023-05-31 10:27:08 -05:00
|
|
|
"crypto/ed25519"
|
|
|
|
"encoding/json"
|
|
|
|
"time"
|
|
|
|
|
2023-04-28 10:46:01 -05:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
2020-05-04 07:53:47 -05:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2023-04-19 09:50:33 -05:00
|
|
|
"github.com/matrix-org/gomatrixserverlib/spec"
|
2020-06-11 13:50:40 -05:00
|
|
|
"github.com/matrix-org/util"
|
2020-06-24 03:59:59 -05:00
|
|
|
)
|
|
|
|
|
2023-05-31 10:27:08 -05:00
|
|
|
type PerformCreateRoomRequest struct {
|
|
|
|
InvitedUsers []string
|
|
|
|
RoomName string
|
|
|
|
Visibility string
|
|
|
|
Topic string
|
|
|
|
StatePreset string
|
|
|
|
CreationContent json.RawMessage
|
|
|
|
InitialState []gomatrixserverlib.FledglingEvent
|
|
|
|
RoomAliasName string
|
|
|
|
RoomVersion gomatrixserverlib.RoomVersion
|
|
|
|
PowerLevelContentOverride json.RawMessage
|
|
|
|
IsDirect bool
|
|
|
|
|
|
|
|
UserDisplayName string
|
|
|
|
UserAvatarURL string
|
|
|
|
KeyID gomatrixserverlib.KeyID
|
|
|
|
PrivateKey ed25519.PrivateKey
|
|
|
|
EventTime time.Time
|
2023-10-04 12:21:23 -05:00
|
|
|
|
|
|
|
SenderID string
|
2023-05-31 10:27:08 -05:00
|
|
|
}
|
|
|
|
|
2020-05-04 07:53:47 -05:00
|
|
|
type PerformJoinRequest struct {
|
2023-04-19 09:50:33 -05:00
|
|
|
RoomIDOrAlias string `json:"room_id_or_alias"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
IsGuest bool `json:"is_guest"`
|
|
|
|
Content map[string]interface{} `json:"content"`
|
|
|
|
ServerNames []spec.ServerName `json:"server_names"`
|
|
|
|
Unsigned map[string]interface{} `json:"unsigned"`
|
2023-11-27 14:10:07 -06:00
|
|
|
SenderID spec.SenderID
|
2020-05-04 07:53:47 -05:00
|
|
|
}
|
|
|
|
|
2023-10-12 18:41:45 -05:00
|
|
|
type PerformJoinRequestCryptoIDs struct {
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
IsGuest bool `json:"is_guest"`
|
|
|
|
Content map[string]interface{} `json:"content"`
|
|
|
|
ServerNames []spec.ServerName `json:"server_names"`
|
|
|
|
Unsigned map[string]interface{} `json:"unsigned"`
|
|
|
|
JoinEvent gomatrixserverlib.PDU
|
|
|
|
}
|
|
|
|
|
2020-05-04 07:53:47 -05:00
|
|
|
type PerformLeaveRequest struct {
|
2023-06-12 06:19:25 -05:00
|
|
|
RoomID string
|
|
|
|
Leaver spec.UserID
|
2020-05-04 07:53:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type PerformLeaveResponse struct {
|
2022-02-18 09:05:03 -06:00
|
|
|
Code int `json:"code,omitempty"`
|
|
|
|
Message interface{} `json:"message,omitempty"`
|
2020-05-04 07:53:47 -05:00
|
|
|
}
|
2020-06-11 13:50:40 -05:00
|
|
|
|
2023-07-06 10:15:24 -05:00
|
|
|
type InviteInput struct {
|
|
|
|
RoomID spec.RoomID
|
|
|
|
Inviter spec.UserID
|
|
|
|
Invitee spec.UserID
|
|
|
|
DisplayName string
|
|
|
|
AvatarURL string
|
|
|
|
Reason string
|
|
|
|
IsDirect bool
|
|
|
|
KeyID gomatrixserverlib.KeyID
|
|
|
|
PrivateKey ed25519.PrivateKey
|
|
|
|
EventTime time.Time
|
|
|
|
}
|
|
|
|
|
2020-06-24 09:06:14 -05:00
|
|
|
type PerformInviteRequest struct {
|
2023-07-06 10:15:24 -05:00
|
|
|
InviteInput InviteInput
|
2023-05-31 11:33:49 -05:00
|
|
|
InviteRoomState []gomatrixserverlib.InviteStrippedState `json:"invite_room_state"`
|
|
|
|
SendAsServer string `json:"send_as_server"`
|
|
|
|
TransactionID *TransactionID `json:"transaction_id"`
|
2020-06-24 09:06:14 -05:00
|
|
|
}
|
|
|
|
|
2020-09-10 08:39:18 -05:00
|
|
|
type PerformPeekRequest struct {
|
2023-04-19 09:50:33 -05:00
|
|
|
RoomIDOrAlias string `json:"room_id_or_alias"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
DeviceID string `json:"device_id"`
|
|
|
|
ServerNames []spec.ServerName `json:"server_names"`
|
2020-09-10 08:39:18 -05:00
|
|
|
}
|
|
|
|
|
2020-06-11 13:50:40 -05:00
|
|
|
// PerformBackfillRequest is a request to PerformBackfill.
|
|
|
|
type PerformBackfillRequest struct {
|
|
|
|
// The room to backfill
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
// A map of backwards extremity event ID to a list of its prev_event IDs.
|
|
|
|
BackwardsExtremities map[string][]string `json:"backwards_extremities"`
|
|
|
|
// The maximum number of events to retrieve.
|
|
|
|
Limit int `json:"limit"`
|
|
|
|
// The server interested in the events.
|
2023-04-19 09:50:33 -05:00
|
|
|
ServerName spec.ServerName `json:"server_name"`
|
2022-11-15 09:05:23 -06:00
|
|
|
// Which virtual host are we doing this for?
|
2023-04-19 09:50:33 -05:00
|
|
|
VirtualHost spec.ServerName `json:"virtual_host"`
|
2020-06-11 13:50:40 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// PrevEventIDs returns the prev_event IDs of all backwards extremities, de-duplicated in a lexicographically sorted order.
|
|
|
|
func (r *PerformBackfillRequest) PrevEventIDs() []string {
|
|
|
|
var prevEventIDs []string
|
|
|
|
for _, pes := range r.BackwardsExtremities {
|
|
|
|
prevEventIDs = append(prevEventIDs, pes...)
|
|
|
|
}
|
|
|
|
prevEventIDs = util.UniqueStrings(prevEventIDs)
|
|
|
|
return prevEventIDs
|
|
|
|
}
|
|
|
|
|
|
|
|
// PerformBackfillResponse is a response to PerformBackfill.
|
|
|
|
type PerformBackfillResponse struct {
|
|
|
|
// Missing events, arbritrary order.
|
2023-04-27 06:54:20 -05:00
|
|
|
Events []*types.HeaderedEvent `json:"events"`
|
2022-08-19 04:04:26 -05:00
|
|
|
HistoryVisibility gomatrixserverlib.HistoryVisibility `json:"history_visibility"`
|
2020-06-11 13:50:40 -05:00
|
|
|
}
|
2020-07-02 09:41:18 -05:00
|
|
|
|
|
|
|
type PerformPublishRequest struct {
|
2022-10-27 07:40:35 -05:00
|
|
|
RoomID string
|
|
|
|
Visibility string
|
|
|
|
AppserviceID string
|
|
|
|
NetworkID string
|
2020-07-02 09:41:18 -05:00
|
|
|
}
|
|
|
|
|
2021-01-22 08:55:08 -06:00
|
|
|
type PerformInboundPeekRequest struct {
|
2023-04-19 09:50:33 -05:00
|
|
|
UserID string `json:"user_id"`
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
PeekID string `json:"peek_id"`
|
|
|
|
ServerName spec.ServerName `json:"server_name"`
|
|
|
|
RenewalInterval int64 `json:"renewal_interval"`
|
2021-01-22 08:55:08 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
type PerformInboundPeekResponse struct {
|
|
|
|
// Does the room exist on this roomserver?
|
|
|
|
// If the room doesn't exist this will be false and StateEvents will be empty.
|
|
|
|
RoomExists bool `json:"room_exists"`
|
|
|
|
// The room version of the room.
|
|
|
|
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
|
|
|
// The current state and auth chain events.
|
|
|
|
// The lists will be in an arbitrary order.
|
2023-04-27 06:54:20 -05:00
|
|
|
StateEvents []*types.HeaderedEvent `json:"state_events"`
|
|
|
|
AuthChainEvents []*types.HeaderedEvent `json:"auth_chain_events"`
|
2021-01-22 08:55:08 -06:00
|
|
|
// The event at which this state was captured
|
2023-04-27 06:54:20 -05:00
|
|
|
LatestEvent *types.HeaderedEvent `json:"latest_event"`
|
2021-01-22 08:55:08 -06:00
|
|
|
}
|
|
|
|
|
2020-11-05 04:19:23 -06:00
|
|
|
// PerformForgetRequest is a request to PerformForget
|
|
|
|
type PerformForgetRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformForgetResponse struct{}
|