api

package
v0.10.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2022 License: Apache-2.0 Imports: 14 Imported by: 129

Documentation

Overview

Package api provides the types that are used to communicate with the roomserver.

Index

Constants

View Source
const DoNotSendToOtherServers = ""

DoNotSendToOtherServers tells us not to send the event to other matrix servers.

Variables

This section is empty.

Functions

func GetEvent

func GetEvent(ctx context.Context, rsAPI QueryEventsAPI, eventID string) *gomatrixserverlib.HeaderedEvent

GetEvent returns the event or nil, even on errors.

func GetStateEvent

GetStateEvent returns the current state event in the room or nil.

func IsServerBannedFromRoom

func IsServerBannedFromRoom(ctx context.Context, rsAPI FederationRoomserverAPI, roomID string, serverName gomatrixserverlib.ServerName) bool

IsServerBannedFromRoom returns whether the server is banned from a room by server ACLs.

func PopulatePublicRooms

func PopulatePublicRooms(ctx context.Context, roomIDs []string, rsAPI QueryBulkStateContentAPI) ([]gomatrixserverlib.PublicRoom, error)

PopulatePublicRooms extracts PublicRoom information for all the provided room IDs. The IDs are not checked to see if they are visible in the published room directory. due to lots of switches

func SendEventWithState

func SendEventWithState(
	ctx context.Context, rsAPI InputRoomEventsAPI, kind Kind,
	state *gomatrixserverlib.RespState, event *gomatrixserverlib.HeaderedEvent,
	origin gomatrixserverlib.ServerName, haveEventIDs map[string]bool, async bool,
) error

SendEventWithState writes an event with the specified kind to the roomserver with the state at the event as KindOutlier before it. Will not send any event that is marked as `true` in haveEventIDs.

func SendEvents

func SendEvents(
	ctx context.Context, rsAPI InputRoomEventsAPI,
	kind Kind, events []*gomatrixserverlib.HeaderedEvent,
	origin gomatrixserverlib.ServerName,
	sendAsServer gomatrixserverlib.ServerName, txnID *TransactionID,
	async bool,
) error

SendEvents to the roomserver The events are written with KindNew.

func SendInputRoomEvents

func SendInputRoomEvents(
	ctx context.Context, rsAPI InputRoomEventsAPI,
	ires []InputRoomEvent, async bool,
) error

SendInputRoomEvents to the roomserver.

Types

type AliasEvent added in v0.7.0

type AliasEvent struct {
	Alias      string   `json:"alias"`
	AltAliases []string `json:"alt_aliases"`
}

func (AliasEvent) Valid added in v0.7.0

func (a AliasEvent) Valid() bool

type AppserviceRoomserverAPI added in v0.8.3

type AppserviceRoomserverAPI interface {
	// Query a list of events by event ID.
	QueryEventsByID(
		ctx context.Context,
		req *QueryEventsByIDRequest,
		res *QueryEventsByIDResponse,
	) error
	// Query a list of membership events for a room
	QueryMembershipsForRoom(
		ctx context.Context,
		req *QueryMembershipsForRoomRequest,
		res *QueryMembershipsForRoomResponse,
	) error
	// Get all known aliases for a room ID
	GetAliasesForRoomID(
		ctx context.Context,
		req *GetAliasesForRoomIDRequest,
		res *GetAliasesForRoomIDResponse,
	) error
}

type ClientRoomserverAPI added in v0.8.3

type ClientRoomserverAPI interface {
	InputRoomEventsAPI
	QueryLatestEventsAndStateAPI
	QueryBulkStateContentAPI
	QueryEventsAPI
	QueryMembershipForUser(ctx context.Context, req *QueryMembershipForUserRequest, res *QueryMembershipForUserResponse) error
	QueryMembershipsForRoom(ctx context.Context, req *QueryMembershipsForRoomRequest, res *QueryMembershipsForRoomResponse) error
	QueryRoomsForUser(ctx context.Context, req *QueryRoomsForUserRequest, res *QueryRoomsForUserResponse) error
	QueryStateAfterEvents(ctx context.Context, req *QueryStateAfterEventsRequest, res *QueryStateAfterEventsResponse) error
	// QueryKnownUsers returns a list of users that we know about from our joined rooms.
	QueryKnownUsers(ctx context.Context, req *QueryKnownUsersRequest, res *QueryKnownUsersResponse) error
	QueryRoomVersionForRoom(ctx context.Context, req *QueryRoomVersionForRoomRequest, res *QueryRoomVersionForRoomResponse) error
	QueryPublishedRooms(ctx context.Context, req *QueryPublishedRoomsRequest, res *QueryPublishedRoomsResponse) error
	QueryRoomVersionCapabilities(ctx context.Context, req *QueryRoomVersionCapabilitiesRequest, res *QueryRoomVersionCapabilitiesResponse) error

	GetRoomIDForAlias(ctx context.Context, req *GetRoomIDForAliasRequest, res *GetRoomIDForAliasResponse) error
	GetAliasesForRoomID(ctx context.Context, req *GetAliasesForRoomIDRequest, res *GetAliasesForRoomIDResponse) error

	// PerformRoomUpgrade upgrades a room to a newer version
	PerformRoomUpgrade(ctx context.Context, req *PerformRoomUpgradeRequest, resp *PerformRoomUpgradeResponse) error
	PerformAdminEvacuateRoom(ctx context.Context, req *PerformAdminEvacuateRoomRequest, res *PerformAdminEvacuateRoomResponse) error
	PerformAdminEvacuateUser(ctx context.Context, req *PerformAdminEvacuateUserRequest, res *PerformAdminEvacuateUserResponse) error
	PerformAdminDownloadState(ctx context.Context, req *PerformAdminDownloadStateRequest, res *PerformAdminDownloadStateResponse) error
	PerformPeek(ctx context.Context, req *PerformPeekRequest, res *PerformPeekResponse) error
	PerformUnpeek(ctx context.Context, req *PerformUnpeekRequest, res *PerformUnpeekResponse) error
	PerformInvite(ctx context.Context, req *PerformInviteRequest, res *PerformInviteResponse) error
	PerformJoin(ctx context.Context, req *PerformJoinRequest, res *PerformJoinResponse) error
	PerformLeave(ctx context.Context, req *PerformLeaveRequest, res *PerformLeaveResponse) error
	PerformPublish(ctx context.Context, req *PerformPublishRequest, res *PerformPublishResponse) error
	// PerformForget forgets a rooms history for a specific user
	PerformForget(ctx context.Context, req *PerformForgetRequest, resp *PerformForgetResponse) error
	SetRoomAlias(ctx context.Context, req *SetRoomAliasRequest, res *SetRoomAliasResponse) error
	RemoveRoomAlias(ctx context.Context, req *RemoveRoomAliasRequest, res *RemoveRoomAliasResponse) error
}

type FederationRoomserverAPI added in v0.8.3

type FederationRoomserverAPI interface {
	InputRoomEventsAPI
	QueryLatestEventsAndStateAPI
	QueryBulkStateContentAPI
	// QueryServerBannedFromRoom returns whether a server is banned from a room by server ACLs.
	QueryServerBannedFromRoom(ctx context.Context, req *QueryServerBannedFromRoomRequest, res *QueryServerBannedFromRoomResponse) error
	QueryRoomVersionForRoom(ctx context.Context, req *QueryRoomVersionForRoomRequest, res *QueryRoomVersionForRoomResponse) error
	GetRoomIDForAlias(ctx context.Context, req *GetRoomIDForAliasRequest, res *GetRoomIDForAliasResponse) error
	QueryEventsByID(ctx context.Context, req *QueryEventsByIDRequest, res *QueryEventsByIDResponse) error
	// Query to get state and auth chain for a (potentially hypothetical) event.
	// Takes lists of PrevEventIDs and AuthEventsIDs and uses them to calculate
	// the state and auth chain to return.
	QueryStateAndAuthChain(ctx context.Context, req *QueryStateAndAuthChainRequest, res *QueryStateAndAuthChainResponse) error
	// Query if we think we're still in a room.
	QueryServerJoinedToRoom(ctx context.Context, req *QueryServerJoinedToRoomRequest, res *QueryServerJoinedToRoomResponse) error
	QueryPublishedRooms(ctx context.Context, req *QueryPublishedRoomsRequest, res *QueryPublishedRoomsResponse) error
	// Query missing events for a room from roomserver
	QueryMissingEvents(ctx context.Context, req *QueryMissingEventsRequest, res *QueryMissingEventsResponse) error
	// Query whether a server is allowed to see an event
	QueryServerAllowedToSeeEvent(ctx context.Context, req *QueryServerAllowedToSeeEventRequest, res *QueryServerAllowedToSeeEventResponse) error
	QueryRoomsForUser(ctx context.Context, req *QueryRoomsForUserRequest, res *QueryRoomsForUserResponse) error
	QueryRestrictedJoinAllowed(ctx context.Context, req *QueryRestrictedJoinAllowedRequest, res *QueryRestrictedJoinAllowedResponse) error
	PerformInboundPeek(ctx context.Context, req *PerformInboundPeekRequest, res *PerformInboundPeekResponse) error
	PerformInvite(ctx context.Context, req *PerformInviteRequest, res *PerformInviteResponse) error
	// Query a given amount (or less) of events prior to a given set of events.
	PerformBackfill(ctx context.Context, req *PerformBackfillRequest, res *PerformBackfillResponse) error
}

type GetAliasesForRoomIDRequest

type GetAliasesForRoomIDRequest struct {
	// The room ID we want to find aliases for
	RoomID string `json:"room_id"`
}

GetAliasesForRoomIDRequest is a request to GetAliasesForRoomID

type GetAliasesForRoomIDResponse

type GetAliasesForRoomIDResponse struct {
	// The aliases the alias refers to
	Aliases []string `json:"aliases"`
}

GetAliasesForRoomIDResponse is a response to GetAliasesForRoomID

type GetRoomIDForAliasRequest

type GetRoomIDForAliasRequest struct {
	// Alias we want to lookup
	Alias string `json:"alias"`
	// Should we ask appservices for their aliases as a part of
	// the request?
	IncludeAppservices bool `json:"include_appservices"`
}

GetRoomIDForAliasRequest is a request to GetRoomIDForAlias

type GetRoomIDForAliasResponse

type GetRoomIDForAliasResponse struct {
	// The room ID the alias refers to
	RoomID string `json:"room_id"`
}

GetRoomIDForAliasResponse is a response to GetRoomIDForAlias

type InputRoomEvent

type InputRoomEvent struct {
	// Whether this event is new, backfilled or an outlier.
	// This controls how the event is processed.
	Kind Kind `json:"kind"`
	// The event JSON for the event to add.
	Event *gomatrixserverlib.HeaderedEvent `json:"event"`
	// Which server told us about this event.
	Origin gomatrixserverlib.ServerName `json:"origin"`
	// Whether the state is supplied as a list of event IDs or whether it
	// should be derived from the state at the previous events.
	HasState bool `json:"has_state"`
	// Optional list of state event IDs forming the state before this event.
	// These state events must have already been persisted.
	// These are only used if HasState is true.
	// The list can be empty, for example when storing the first event in a room.
	StateEventIDs []string `json:"state_event_ids"`
	// The server name to use to push this event to other servers.
	// Or empty if this event shouldn't be pushed to other servers.
	SendAsServer string `json:"send_as_server"`
	// The transaction ID of the send request if sent by a local user and one
	// was specified
	TransactionID *TransactionID `json:"transaction_id"`
}

InputRoomEvent is a matrix room event to add to the room server database. TODO: Implement UnmarshalJSON/MarshalJSON in a way that does something sensible with the event JSON.

type InputRoomEventsAPI added in v0.8.3

type InputRoomEventsAPI interface {
	InputRoomEvents(
		ctx context.Context,
		req *InputRoomEventsRequest,
		res *InputRoomEventsResponse,
	) error
}

type InputRoomEventsRequest

type InputRoomEventsRequest struct {
	InputRoomEvents []InputRoomEvent `json:"input_room_events"`
	Asynchronous    bool             `json:"async"`
}

InputRoomEventsRequest is a request to InputRoomEvents

type InputRoomEventsResponse

type InputRoomEventsResponse struct {
	ErrMsg     string // set if there was any error
	NotAllowed bool   // true if an event in the input was not allowed.
}

InputRoomEventsResponse is a response to InputRoomEvents

func (*InputRoomEventsResponse) Err

func (r *InputRoomEventsResponse) Err() error

type Kind added in v0.2.0

type Kind int
const (
	// KindOutlier event fall outside the contiguous event graph.
	// We do not have the state for these events.
	// These events are state events used to authenticate other events.
	// They can become part of the contiguous event graph via backfill.
	KindOutlier Kind = iota + 1
	// KindNew event extend the contiguous graph going forwards.
	// They usually don't need state, but may include state if the
	// there was a new event that references an event that we don't
	// have a copy of. New events will influence the fwd extremities
	// of the room and output events will be generated as a result.
	KindNew
	// KindOld event extend the graph backwards, or fill gaps in
	// history. They may or may not include state. They will not be
	// considered for forward extremities, and output events will NOT
	// be generated for them.
	KindOld
)

func (Kind) String added in v0.6.1

func (k Kind) String() string

type OutputEvent

type OutputEvent struct {
	// What sort of event this is.
	Type OutputType `json:"type"`
	// The content of event with type OutputTypeNewRoomEvent
	NewRoomEvent *OutputNewRoomEvent `json:"new_room_event,omitempty"`
	// The content of event with type OutputTypeOldRoomEvent
	OldRoomEvent *OutputOldRoomEvent `json:"old_room_event,omitempty"`
	// The content of event with type OutputTypeNewInviteEvent
	NewInviteEvent *OutputNewInviteEvent `json:"new_invite_event,omitempty"`
	// The content of event with type OutputTypeRetireInviteEvent
	RetireInviteEvent *OutputRetireInviteEvent `json:"retire_invite_event,omitempty"`
	// The content of event with type OutputTypeRedactedEvent
	RedactedEvent *OutputRedactedEvent `json:"redacted_event,omitempty"`
	// The content of event with type OutputTypeNewPeek
	NewPeek *OutputNewPeek `json:"new_peek,omitempty"`
	// The content of event with type OutputTypeNewInboundPeek
	NewInboundPeek *OutputNewInboundPeek `json:"new_inbound_peek,omitempty"`
	// The content of event with type OutputTypeRetirePeek
	RetirePeek *OutputRetirePeek `json:"retire_peek,omitempty"`
}

An OutputEvent is an entry in the roomserver output kafka log. Consumers should check the type field when consuming this event.

type OutputNewInboundPeek added in v0.3.7

type OutputNewInboundPeek struct {
	RoomID string
	PeekID string
	// the event ID at which the peek begins (so we can avoid
	// a race between tracking the state returned by /peek and emitting subsequent
	// peeked events)
	LatestEventID string
	ServerName    gomatrixserverlib.ServerName
	// how often we told the peeking server to renew the peek
	RenewalInterval int64
}

An OutputNewInboundPeek is written whenever a server starts peeking into a room

type OutputNewInviteEvent

type OutputNewInviteEvent struct {
	// The room version of the invited room.
	RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
	// The "m.room.member" invite event.
	Event *gomatrixserverlib.HeaderedEvent `json:"event"`
}

An OutputNewInviteEvent is written whenever an invite becomes active. Invite events can be received outside of an existing room so have to be tracked separately from the room events themselves.

type OutputNewPeek

type OutputNewPeek struct {
	RoomID   string
	UserID   string
	DeviceID string
}

An OutputNewPeek is written whenever a user starts peeking into a room using a given device.

type OutputNewRoomEvent

type OutputNewRoomEvent struct {
	// The Event.
	Event *gomatrixserverlib.HeaderedEvent `json:"event"`
	// Does the event completely rewrite the room state? If so, then AddsStateEventIDs
	// will contain the entire room state.
	RewritesState bool `json:"rewrites_state,omitempty"`
	// The latest events in the room after this event.
	// This can be used to set the prev events for new events in the room.
	// This also can be used to get the full current state after this event.
	LatestEventIDs []string `json:"latest_event_ids"`
	// The state event IDs that were added to the state of the room by this event.
	// Together with RemovesStateEventIDs this allows the receiver to keep an up to date
	// view of the current state of the room.
	AddsStateEventIDs []string `json:"adds_state_event_ids,omitempty"`
	// The state event IDs that were removed from the state of the room by this event.
	RemovesStateEventIDs []string `json:"removes_state_event_ids,omitempty"`
	// The ID of the event that was output before this event.
	// Or the empty string if this is the first event output for this room.
	// This is used by consumers to check if they can safely update their
	// current state using the delta supplied in AddsStateEventIDs and
	// RemovesStateEventIDs.
	//
	// If the LastSentEventID doesn't match what they were expecting it to be
	// they can use the LatestEventIDs to request the full current state.
	LastSentEventID string `json:"last_sent_event_id"`
	// The state event IDs that are part of the state at the event, but not
	// part of the current state. Together with the StateBeforeRemovesEventIDs
	// this can be used to construct the state before the event from the
	// current state. The StateBeforeAddsEventIDs and StateBeforeRemovesEventIDs
	// delta is applied after the AddsStateEventIDs and RemovesStateEventIDs.
	//
	// Consumers need to know the state at each event in order to determine
	// which users and servers are allowed to see the event. This information
	// is needed to apply the history visibility rules and to tell which
	// servers we need to push events to over federation.
	//
	// The state is given as a delta against the current state because they are
	// usually either the same state, or differ by just a couple of events.
	StateBeforeAddsEventIDs []string `json:"state_before_adds_event_ids,omitempty"`
	// The state event IDs that are part of the current state, but not part
	// of the state at the event.
	StateBeforeRemovesEventIDs []string `json:"state_before_removes_event_ids,omitempty"`
	// The server name to use to push this event to other servers.
	// Or empty if this event shouldn't be pushed to other servers.
	//
	// This is used by the federation sender component. We need to tell it what
	// event it needs to send because it can't tell on its own. Normally if an
	// event was created on this server then we are responsible for sending it.
	// However there are a couple of exceptions. The first is that when the
	// server joins a remote room through another matrix server, it is the job
	// of the other matrix server to send the event over federation. The second
	// is the reverse of the first, that is when a remote server joins a room
	// that we are in over federation using our server it is our responsibility
	// to send the join event to other matrix servers.
	//
	// We encode the server name that the event should be sent using here to
	// future proof the API for virtual hosting.
	SendAsServer string `json:"send_as_server"`
	// The transaction ID of the send request if sent by a local user and one
	// was specified
	TransactionID *TransactionID `json:"transaction_id,omitempty"`
	// The history visibility of the event.
	HistoryVisibility gomatrixserverlib.HistoryVisibility `json:"history_visibility"`
}

An OutputNewRoomEvent is written when the roomserver receives a new event. It contains the full matrix room event and enough information for a consumer to construct the current state of the room and the state before the event.

When we talk about state in a matrix room we are talking about the state after a list of events. The current state is the state after the latest event IDs in the room. The state before an event is the state after its prev_events.

func (*OutputNewRoomEvent) NeededStateEventIDs added in v0.8.3

func (o *OutputNewRoomEvent) NeededStateEventIDs() ([]*gomatrixserverlib.HeaderedEvent, []string)

type OutputOldRoomEvent added in v0.2.0

type OutputOldRoomEvent struct {
	// The Event.
	Event             *gomatrixserverlib.HeaderedEvent    `json:"event"`
	HistoryVisibility gomatrixserverlib.HistoryVisibility `json:"history_visibility"`
}

An OutputOldRoomEvent is written when the roomserver receives an old event. This will typically happen as a result of getting either missing events or backfilling. Downstream components may wish to send these events to clients when it is advantageous to do so, but with the consideration that the event is likely a historic event.

Old events do not update forward extremities or the current room state, therefore they must not be treated as if they do. Downstream components should build their current room state up from OutputNewRoomEvents only.

type OutputRedactedEvent

type OutputRedactedEvent struct {
	// The event ID that was redacted
	RedactedEventID string
	// The value of `unsigned.redacted_because` - the redaction event itself
	RedactedBecause *gomatrixserverlib.HeaderedEvent
}

An OutputRedactedEvent is written whenever a redaction has been /validated/. Downstream components MUST redact the given event ID if they have stored the event JSON. It is guaranteed that this event ID has been seen before.

type OutputRetireInviteEvent

type OutputRetireInviteEvent struct {
	// The ID of the "m.room.member" invite event.
	EventID string
	// The target user ID of the "m.room.member" invite event that was retired.
	TargetUserID string
	// Optional event ID of the event that replaced the invite.
	// This can be empty if the invite was rejected locally and we were unable
	// to reach the server that originally sent the invite.
	RetiredByEventID string
	// The "membership" of the user after retiring the invite. One of "join"
	// "leave" or "ban".
	Membership string
}

An OutputRetireInviteEvent is written whenever an existing invite is no longer active. An invite stops being active if the user joins the room or if the invite is rejected by the user.

type OutputRetirePeek added in v0.3.3

type OutputRetirePeek struct {
	RoomID   string
	UserID   string
	DeviceID string
}

An OutputRetirePeek is written whenever a user stops peeking into a room.

type OutputRoomEventType

type OutputRoomEventType int

Type of the OutputNewRoomEvent.

const (
	// The event is a timeline event and likely just happened.
	OutputRoomTimeline OutputRoomEventType = iota

	// The event is a state event and quite possibly happened in the past.
	OutputRoomState
)

type OutputType

type OutputType string

An OutputType is a type of roomserver output.

const (
	// OutputTypeNewRoomEvent indicates that the event is an OutputNewRoomEvent
	OutputTypeNewRoomEvent OutputType = "new_room_event"
	// OutputTypeOldRoomEvent indicates that the event is an OutputOldRoomEvent
	OutputTypeOldRoomEvent OutputType = "old_room_event"
	// OutputTypeNewInviteEvent indicates that the event is an OutputNewInviteEvent
	OutputTypeNewInviteEvent OutputType = "new_invite_event"
	// OutputTypeRetireInviteEvent indicates that the event is an OutputRetireInviteEvent
	OutputTypeRetireInviteEvent OutputType = "retire_invite_event"
	// OutputTypeRedactedEvent indicates that the event is an OutputRedactedEvent
	//
	// This event is emitted when a redaction has been 'validated' (meaning both the redaction and the event to redact are known).
	// Redaction validation happens when the roomserver receives either:
	// - A redaction for which we have the event to redact.
	// - Any event for which we have a redaction.
	// When the roomserver receives an event, it will check against the redactions table to see if there is a matching redaction
	// for the event. If there is, it will mark the redaction as validated and emit this event. In the common case of a redaction
	// happening after receiving the event to redact, the roomserver will emit a OutputTypeNewRoomEvent of m.room.redaction
	// immediately followed by a OutputTypeRedactedEvent. In the uncommon case of receiving the redaction BEFORE the event to redact,
	// the roomserver will emit a OutputTypeNewRoomEvent of the event to redact immediately followed by a OutputTypeRedactedEvent.
	//
	// In order to honour redactions correctly, downstream components must ignore m.room.redaction events emitted via OutputTypeNewRoomEvent.
	// When downstream components receive an OutputTypeRedactedEvent they must:
	// - Pull out the event to redact from the database. They should have this because the redaction is validated.
	// - Redact the event and set the corresponding `unsigned` fields to indicate it as redacted.
	// - Replace the event in the database.
	OutputTypeRedactedEvent OutputType = "redacted_event"

	// OutputTypeNewPeek indicates that the kafka event is an OutputNewPeek
	OutputTypeNewPeek OutputType = "new_peek"
	// OutputTypeNewInboundPeek indicates that the kafka event is an OutputNewInboundPeek
	OutputTypeNewInboundPeek OutputType = "new_inbound_peek"
	// OutputTypeRetirePeek indicates that the kafka event is an OutputRetirePeek
	OutputTypeRetirePeek OutputType = "retire_peek"
)

type PerformAdminDownloadStateRequest added in v0.10.5

type PerformAdminDownloadStateRequest struct {
	RoomID     string                       `json:"room_id"`
	UserID     string                       `json:"user_id"`
	ServerName gomatrixserverlib.ServerName `json:"server_name"`
}

type PerformAdminDownloadStateResponse added in v0.10.5

type PerformAdminDownloadStateResponse struct {
	Error *PerformError `json:"error,omitempty"`
}

type PerformAdminEvacuateRoomRequest added in v0.8.3

type PerformAdminEvacuateRoomRequest struct {
	RoomID string `json:"room_id"`
}

type PerformAdminEvacuateRoomResponse added in v0.8.3

type PerformAdminEvacuateRoomResponse struct {
	Affected []string `json:"affected"`
	Error    *PerformError
}

type PerformAdminEvacuateUserRequest added in v0.8.9

type PerformAdminEvacuateUserRequest struct {
	UserID string `json:"user_id"`
}

type PerformAdminEvacuateUserResponse added in v0.8.9

type PerformAdminEvacuateUserResponse struct {
	Affected []string `json:"affected"`
	Error    *PerformError
}

type PerformBackfillRequest

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.
	ServerName gomatrixserverlib.ServerName `json:"server_name"`
}

PerformBackfillRequest is a request to PerformBackfill.

func (*PerformBackfillRequest) PrevEventIDs

func (r *PerformBackfillRequest) PrevEventIDs() []string

PrevEventIDs returns the prev_event IDs of all backwards extremities, de-duplicated in a lexicographically sorted order.

type PerformBackfillResponse

type PerformBackfillResponse struct {
	// Missing events, arbritrary order.
	Events            []*gomatrixserverlib.HeaderedEvent  `json:"events"`
	HistoryVisibility gomatrixserverlib.HistoryVisibility `json:"history_visibility"`
}

PerformBackfillResponse is a response to PerformBackfill.

type PerformError

type PerformError struct {
	Msg        string
	RemoteCode int // remote HTTP status code, for PerformErrRemote
	Code       PerformErrorCode
}

func (*PerformError) Error

func (p *PerformError) Error() string

func (*PerformError) JSONResponse

func (p *PerformError) JSONResponse() util.JSONResponse

JSONResponse maps error codes to suitable HTTP error codes, defaulting to 500.

type PerformErrorCode

type PerformErrorCode int
const (
	// PerformErrorNotAllowed means the user is not allowed to invite/join/etc this room (e.g join_rule:invite or banned)
	PerformErrorNotAllowed PerformErrorCode = 1
	// PerformErrorBadRequest means the request was wrong in some way (invalid user ID, wrong server, etc)
	PerformErrorBadRequest PerformErrorCode = 2
	// PerformErrorNoRoom means that the room being joined doesn't exist.
	PerformErrorNoRoom PerformErrorCode = 3
	// PerformErrorNoOperation means that the request resulted in nothing happening e.g invite->invite or leave->leave.
	PerformErrorNoOperation PerformErrorCode = 4
	// PerformErrRemote means that the request failed and the PerformError.Msg is the raw remote JSON error response
	PerformErrRemote PerformErrorCode = 5
)

type PerformForgetRequest added in v0.3.0

type PerformForgetRequest struct {
	RoomID string `json:"room_id"`
	UserID string `json:"user_id"`
}

PerformForgetRequest is a request to PerformForget

type PerformForgetResponse added in v0.3.0

type PerformForgetResponse struct{}

type PerformInboundPeekRequest added in v0.3.7

type PerformInboundPeekRequest struct {
	UserID          string                       `json:"user_id"`
	RoomID          string                       `json:"room_id"`
	PeekID          string                       `json:"peek_id"`
	ServerName      gomatrixserverlib.ServerName `json:"server_name"`
	RenewalInterval int64                        `json:"renewal_interval"`
}

type PerformInboundPeekResponse added in v0.3.7

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.
	StateEvents     []*gomatrixserverlib.HeaderedEvent `json:"state_events"`
	AuthChainEvents []*gomatrixserverlib.HeaderedEvent `json:"auth_chain_events"`
	// The event at which this state was captured
	LatestEvent *gomatrixserverlib.HeaderedEvent `json:"latest_event"`
}

type PerformInviteRequest

type PerformInviteRequest struct {
	RoomVersion     gomatrixserverlib.RoomVersion             `json:"room_version"`
	Event           *gomatrixserverlib.HeaderedEvent          `json:"event"`
	InviteRoomState []gomatrixserverlib.InviteV2StrippedState `json:"invite_room_state"`
	SendAsServer    string                                    `json:"send_as_server"`
	TransactionID   *TransactionID                            `json:"transaction_id"`
}

type PerformInviteResponse

type PerformInviteResponse struct {
	Error *PerformError
}

type PerformJoinRequest

type PerformJoinRequest struct {
	RoomIDOrAlias string                         `json:"room_id_or_alias"`
	UserID        string                         `json:"user_id"`
	Content       map[string]interface{}         `json:"content"`
	ServerNames   []gomatrixserverlib.ServerName `json:"server_names"`
	Unsigned      map[string]interface{}         `json:"unsigned"`
}

type PerformJoinResponse

type PerformJoinResponse struct {
	// The room ID, populated on success.
	RoomID    string `json:"room_id"`
	JoinedVia gomatrixserverlib.ServerName
	// If non-nil, the join request failed. Contains more information why it failed.
	Error *PerformError
}

type PerformLeaveRequest

type PerformLeaveRequest struct {
	RoomID string `json:"room_id"`
	UserID string `json:"user_id"`
}

type PerformLeaveResponse

type PerformLeaveResponse struct {
	Code    int         `json:"code,omitempty"`
	Message interface{} `json:"message,omitempty"`
}

type PerformPeekRequest

type PerformPeekRequest struct {
	RoomIDOrAlias string                         `json:"room_id_or_alias"`
	UserID        string                         `json:"user_id"`
	DeviceID      string                         `json:"device_id"`
	ServerNames   []gomatrixserverlib.ServerName `json:"server_names"`
}

type PerformPeekResponse

type PerformPeekResponse struct {
	// The room ID, populated on success.
	RoomID string `json:"room_id"`
	// If non-nil, the join request failed. Contains more information why it failed.
	Error *PerformError
}

type PerformPublishRequest

type PerformPublishRequest struct {
	RoomID       string
	Visibility   string
	AppserviceID string
	NetworkID    string
}

type PerformPublishResponse

type PerformPublishResponse struct {
	// If non-nil, the publish request failed. Contains more information why it failed.
	Error *PerformError
}

type PerformRoomUpgradeRequest added in v0.8.0

type PerformRoomUpgradeRequest struct {
	RoomID      string                        `json:"room_id"`
	UserID      string                        `json:"user_id"`
	RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
}

type PerformRoomUpgradeResponse added in v0.8.0

type PerformRoomUpgradeResponse struct {
	NewRoomID string
	Error     *PerformError
}

type PerformUnpeekRequest added in v0.3.3

type PerformUnpeekRequest struct {
	RoomID   string `json:"room_id"`
	UserID   string `json:"user_id"`
	DeviceID string `json:"device_id"`
}

type PerformUnpeekResponse added in v0.3.3

type PerformUnpeekResponse struct {
	// If non-nil, the join request failed. Contains more information why it failed.
	Error *PerformError
}

type QueryAuthChainRequest added in v0.3.3

type QueryAuthChainRequest struct {
	EventIDs []string
}

type QueryAuthChainResponse added in v0.3.3

type QueryAuthChainResponse struct {
	AuthChain []*gomatrixserverlib.HeaderedEvent
}

type QueryBulkStateContentAPI added in v0.8.3

type QueryBulkStateContentAPI interface {
	QueryBulkStateContent(ctx context.Context, req *QueryBulkStateContentRequest, res *QueryBulkStateContentResponse) error
}

QueryBulkStateContent does a bulk query for state event content in the given rooms.

type QueryBulkStateContentRequest

type QueryBulkStateContentRequest struct {
	// Returns state events in these rooms
	RoomIDs []string
	// If true, treats the '*' StateKey as "all state events of this type" rather than a literal value of '*'
	AllowWildcards bool
	// The state events to return. Only a small subset of tuples are allowed in this request as only certain events
	// have their content fields extracted. Specifically, the tuple Type must be one of:
	//   m.room.avatar
	//   m.room.create
	//   m.room.canonical_alias
	//   m.room.guest_access
	//   m.room.history_visibility
	//   m.room.join_rules
	//   m.room.member
	//   m.room.name
	//   m.room.topic
	// Any other tuple type will result in the query failing.
	StateTuples []gomatrixserverlib.StateKeyTuple
}

type QueryBulkStateContentResponse

type QueryBulkStateContentResponse struct {
	// map of room ID -> tuple -> content_value
	Rooms map[string]map[gomatrixserverlib.StateKeyTuple]string
}

func (*QueryBulkStateContentResponse) MarshalJSON

func (r *QueryBulkStateContentResponse) MarshalJSON() ([]byte, error)

MarshalJSON stringifies the room ID and StateKeyTuple keys so they can be sent over the wire in HTTP API mode.

func (*QueryBulkStateContentResponse) UnmarshalJSON

func (r *QueryBulkStateContentResponse) UnmarshalJSON(data []byte) error

type QueryCurrentStateRequest

type QueryCurrentStateRequest struct {
	RoomID         string
	AllowWildcards bool
	// State key tuples. If a state_key has '*' and AllowWidlcards is true, returns all matching
	// state events with that event type.
	StateTuples []gomatrixserverlib.StateKeyTuple
}

type QueryCurrentStateResponse

type QueryCurrentStateResponse struct {
	StateEvents map[gomatrixserverlib.StateKeyTuple]*gomatrixserverlib.HeaderedEvent
}

func (*QueryCurrentStateResponse) MarshalJSON

func (r *QueryCurrentStateResponse) MarshalJSON() ([]byte, error)

MarshalJSON stringifies the StateKeyTuple keys so they can be sent over the wire in HTTP API mode.

func (*QueryCurrentStateResponse) UnmarshalJSON

func (r *QueryCurrentStateResponse) UnmarshalJSON(data []byte) error

type QueryEventsAPI added in v0.8.3

type QueryEventsAPI interface {
	// Query a list of events by event ID.
	QueryEventsByID(
		ctx context.Context,
		req *QueryEventsByIDRequest,
		res *QueryEventsByIDResponse,
	) error
	// QueryCurrentState retrieves the requested state events. If state events are not found, they will be missing from
	// the response.
	QueryCurrentState(ctx context.Context, req *QueryCurrentStateRequest, res *QueryCurrentStateResponse) error
}

type QueryEventsByIDRequest

type QueryEventsByIDRequest struct {
	// The event IDs to look up.
	EventIDs []string `json:"event_ids"`
}

QueryEventsByIDRequest is a request to QueryEventsByID

type QueryEventsByIDResponse

type QueryEventsByIDResponse struct {
	// A list of events with the requested IDs.
	// If the roomserver does not have a copy of a requested event
	// then it will omit that event from the list.
	// If the roomserver thinks it has a copy of the event, but
	// fails to read it from the database then it will fail
	// the entire request.
	// This list will be in an arbitrary order.
	Events []*gomatrixserverlib.HeaderedEvent `json:"events"`
}

QueryEventsByIDResponse is a response to QueryEventsByID

type QueryKnownUsersRequest

type QueryKnownUsersRequest struct {
	UserID       string `json:"user_id"`
	SearchString string `json:"search_string"`
	Limit        int    `json:"limit"`
}

type QueryKnownUsersResponse

type QueryKnownUsersResponse struct {
	Users []authtypes.FullyQualifiedProfile `json:"profiles"`
}

type QueryLatestEventsAndStateAPI added in v0.8.3

type QueryLatestEventsAndStateAPI interface {
	QueryLatestEventsAndState(ctx context.Context, req *QueryLatestEventsAndStateRequest, res *QueryLatestEventsAndStateResponse) error
}

Query the latest events and state for a room from the room server.

type QueryLatestEventsAndStateRequest

type QueryLatestEventsAndStateRequest struct {
	// The room ID to query the latest events for.
	RoomID string `json:"room_id"`
	// The state key tuples to fetch from the room current state.
	// If this list is empty or nil then *ALL* current state events are returned.
	StateToFetch []gomatrixserverlib.StateKeyTuple `json:"state_to_fetch"`
}

QueryLatestEventsAndStateRequest is a request to QueryLatestEventsAndState

type QueryLatestEventsAndStateResponse

type QueryLatestEventsAndStateResponse struct {
	// Does the room exist?
	// If the room doesn't exist this will be false and LatestEvents will be empty.
	RoomExists bool `json:"room_exists"`
	// The room version of the room.
	RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
	// The latest events in the room.
	// These are used to set the prev_events when sending an event.
	LatestEvents []gomatrixserverlib.EventReference `json:"latest_events"`
	// The state events requested.
	// This list will be in an arbitrary order.
	// These are used to set the auth_events when sending an event.
	// These are used to check whether the event is allowed.
	StateEvents []*gomatrixserverlib.HeaderedEvent `json:"state_events"`
	// The depth of the latest events.
	// This is one greater than the maximum depth of the latest events.
	// This is used to set the depth when sending an event.
	Depth int64 `json:"depth"`
}

QueryLatestEventsAndStateResponse is a response to QueryLatestEventsAndState This is used when sending events to set the prev_events, auth_events and depth. It is also used to tell whether the event is allowed by the event auth rules.

type QueryMembershipAtEventRequest added in v0.9.2

type QueryMembershipAtEventRequest struct {
	RoomID   string
	EventIDs []string
	UserID   string
}

QueryMembershipAtEventRequest requests the membership events for a user for a list of eventIDs.

type QueryMembershipAtEventResponse added in v0.9.2

type QueryMembershipAtEventResponse struct {
	// Memberships is a map from eventID to a list of events (if any). Events that
	// do not have known state will return an empty array here.
	Memberships map[string][]*gomatrixserverlib.HeaderedEvent `json:"memberships"`
}

QueryMembershipAtEventResponse is the response to QueryMembershipAtEventRequest.

type QueryMembershipForUserRequest

type QueryMembershipForUserRequest struct {
	// ID of the room to fetch membership from
	RoomID string `json:"room_id"`
	// ID of the user for whom membership is requested
	UserID string `json:"user_id"`
}

QueryMembershipForUserRequest is a request to QueryMembership

type QueryMembershipForUserResponse

type QueryMembershipForUserResponse struct {
	// The EventID of the latest "m.room.member" event for the sender,
	// if HasBeenInRoom is true.
	EventID string `json:"event_id"`
	// True if the user has been in room before and has either stayed in it or left it.
	HasBeenInRoom bool `json:"has_been_in_room"`
	// True if the user is in room.
	IsInRoom bool `json:"is_in_room"`
	// The current membership
	Membership string `json:"membership"`
	// True if the user asked to forget this room.
	IsRoomForgotten bool `json:"is_room_forgotten"`
	RoomExists      bool `json:"room_exists"`
}

QueryMembershipForUserResponse is a response to QueryMembership

type QueryMembershipsForRoomRequest

type QueryMembershipsForRoomRequest struct {
	// If true, only returns the membership events of "join" membership
	JoinedOnly bool `json:"joined_only"`
	// If true, only returns the membership events of local users
	LocalOnly bool `json:"local_only"`
	// ID of the room to fetch memberships from
	RoomID string `json:"room_id"`
	// Optional - ID of the user sending the request, for checking if the
	// user is allowed to see the memberships. If not specified then all
	// room memberships will be returned.
	Sender string `json:"sender"`
}

QueryMembershipsForRoomRequest is a request to QueryMembershipsForRoom

type QueryMembershipsForRoomResponse

type QueryMembershipsForRoomResponse struct {
	// The "m.room.member" events (of "join" membership) in the client format
	JoinEvents []gomatrixserverlib.ClientEvent `json:"join_events"`
	// True if the user has been in room before and has either stayed in it or
	// left it.
	HasBeenInRoom bool `json:"has_been_in_room"`
	// True if the user asked to forget this room.
	IsRoomForgotten bool `json:"is_room_forgotten"`
}

QueryMembershipsForRoomResponse is a response to QueryMembershipsForRoom

type QueryMissingEventsRequest

type QueryMissingEventsRequest struct {
	// Events which are known previous to the gap in the timeline.
	EarliestEvents []string `json:"earliest_events"`
	// Latest known events.
	LatestEvents []string `json:"latest_events"`
	// Limit the number of events this query returns.
	Limit int `json:"limit"`
	// The server interested in the event
	ServerName gomatrixserverlib.ServerName `json:"server_name"`
}

QueryMissingEventsRequest is a request to QueryMissingEvents

type QueryMissingEventsResponse

type QueryMissingEventsResponse struct {
	// Missing events, arbritrary order.
	Events []*gomatrixserverlib.HeaderedEvent `json:"events"`
}

QueryMissingEventsResponse is a response to QueryMissingEvents

type QueryPublishedRoomsRequest

type QueryPublishedRoomsRequest struct {
	// Optional. If specified, returns whether this room is published or not.
	RoomID             string
	NetworkID          string
	IncludeAllNetworks bool
}

type QueryPublishedRoomsResponse

type QueryPublishedRoomsResponse struct {
	// The list of published rooms.
	RoomIDs []string
}

type QueryRestrictedJoinAllowedRequest added in v0.8.6

type QueryRestrictedJoinAllowedRequest struct {
	UserID string `json:"user_id"`
	RoomID string `json:"room_id"`
}

type QueryRestrictedJoinAllowedResponse added in v0.8.6

type QueryRestrictedJoinAllowedResponse struct {
	// True if the room membership is restricted by the join rule being set to "restricted"
	Restricted bool `json:"restricted"`
	// True if our local server is joined to all of the allowed rooms specified in the "allow"
	// key of the join rule, false if we are missing from some of them and therefore can't
	// reliably decide whether or not we can satisfy the join
	Resident bool `json:"resident"`
	// True if the restricted join is allowed because we found the membership in one of the
	// allowed rooms from the join rule, false if not
	Allowed bool `json:"allowed"`
	// Contains the user ID of the selected user ID that has power to issue invites, this will
	// get populated into the "join_authorised_via_users_server" content in the membership
	AuthorisedVia string `json:"authorised_via,omitempty"`
}

type QueryRoomVersionCapabilitiesRequest

type QueryRoomVersionCapabilitiesRequest struct{}

QueryRoomVersionCapabilitiesRequest asks for the default room version

type QueryRoomVersionCapabilitiesResponse

type QueryRoomVersionCapabilitiesResponse struct {
	DefaultRoomVersion    gomatrixserverlib.RoomVersion            `json:"default"`
	AvailableRoomVersions map[gomatrixserverlib.RoomVersion]string `json:"available"`
}

QueryRoomVersionCapabilitiesResponse is a response to QueryRoomVersionCapabilitiesRequest

type QueryRoomVersionForRoomRequest

type QueryRoomVersionForRoomRequest struct {
	RoomID string `json:"room_id"`
}

QueryRoomVersionForRoomRequest asks for the room version for a given room.

type QueryRoomVersionForRoomResponse

type QueryRoomVersionForRoomResponse struct {
	RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
}

QueryRoomVersionForRoomResponse is a response to QueryRoomVersionForRoomRequest

type QueryRoomsForUserRequest

type QueryRoomsForUserRequest struct {
	UserID string
	// The desired membership of the user. If this is the empty string then no rooms are returned.
	WantMembership string
}

type QueryRoomsForUserResponse

type QueryRoomsForUserResponse struct {
	RoomIDs []string
}

type QueryServerAllowedToSeeEventRequest

type QueryServerAllowedToSeeEventRequest struct {
	// The event ID to look up invites in.
	EventID string `json:"event_id"`
	// The server interested in the event
	ServerName gomatrixserverlib.ServerName `json:"server_name"`
}

QueryServerAllowedToSeeEventRequest is a request to QueryServerAllowedToSeeEvent

type QueryServerAllowedToSeeEventResponse

type QueryServerAllowedToSeeEventResponse struct {
	// Wether the server in question is allowed to see the event
	AllowedToSeeEvent bool `json:"can_see_event"`
}

QueryServerAllowedToSeeEventResponse is a response to QueryServerAllowedToSeeEvent

type QueryServerBannedFromRoomRequest

type QueryServerBannedFromRoomRequest struct {
	ServerName gomatrixserverlib.ServerName `json:"server_name"`
	RoomID     string                       `json:"room_id"`
}

type QueryServerBannedFromRoomResponse

type QueryServerBannedFromRoomResponse struct {
	Banned bool `json:"banned"`
}

type QueryServerJoinedToRoomRequest

type QueryServerJoinedToRoomRequest struct {
	// Server name of the server to find. If not specified, we will
	// default to checking if the local server is joined.
	ServerName gomatrixserverlib.ServerName `json:"server_name"`
	// ID of the room to see if we are still joined to
	RoomID string `json:"room_id"`
}

QueryServerJoinedToRoomRequest is a request to QueryServerJoinedToRoom

type QueryServerJoinedToRoomResponse

type QueryServerJoinedToRoomResponse struct {
	// True if the room exists on the server
	RoomExists bool `json:"room_exists"`
	// True if we still believe that the server is participating in the room
	IsInRoom bool `json:"is_in_room"`
}

QueryMembershipsForRoomResponse is a response to QueryServerJoinedToRoom

type QuerySharedUsersRequest

type QuerySharedUsersRequest struct {
	UserID         string
	OtherUserIDs   []string
	ExcludeRoomIDs []string
	IncludeRoomIDs []string
	LocalOnly      bool
}

type QuerySharedUsersResponse

type QuerySharedUsersResponse struct {
	UserIDsToCount map[string]int
}

type QueryStateAfterEventsRequest

type QueryStateAfterEventsRequest struct {
	// The room ID to query the state in.
	RoomID string `json:"room_id"`
	// The list of previous events to return the events after.
	PrevEventIDs []string `json:"prev_event_ids"`
	// The state key tuples to fetch from the state. If none are specified then
	// the entire resolved room state will be returned.
	StateToFetch []gomatrixserverlib.StateKeyTuple `json:"state_to_fetch"`
}

QueryStateAfterEventsRequest is a request to QueryStateAfterEvents

type QueryStateAfterEventsResponse

type QueryStateAfterEventsResponse 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"`
	// Do all the previous events exist on this roomserver?
	// If some of previous events do not exist this will be false and StateEvents will be empty.
	PrevEventsExist bool `json:"prev_events_exist"`
	// The state events requested.
	// This list will be in an arbitrary order.
	StateEvents []*gomatrixserverlib.HeaderedEvent `json:"state_events"`
}

QueryStateAfterEventsResponse is a response to QueryStateAfterEvents

type QueryStateAndAuthChainRequest

type QueryStateAndAuthChainRequest struct {
	// The room ID to query the state in.
	RoomID string `json:"room_id"`
	// The list of prev events for the event. Used to calculate the state at
	// the event.
	PrevEventIDs []string `json:"prev_event_ids"`
	// The list of auth events for the event. Used to calculate the auth chain
	AuthEventIDs []string `json:"auth_event_ids"`
	// If true, the auth chain events for the auth event IDs given will be fetched only. Prev event IDs are ignored.
	// If false, state and auth chain events for the prev event IDs and entire current state will be included.
	// TODO: not a great API shape. It serves 2 main uses: false=>response for send_join, true=>response for /event_auth
	OnlyFetchAuthChain bool `json:"only_fetch_auth_chain"`
	// Should state resolution be ran on the result events?
	// TODO: check call sites and remove if we always want to do state res
	ResolveState bool `json:"resolve_state"`
}

QueryStateAndAuthChainRequest is a request to QueryStateAndAuthChain

type QueryStateAndAuthChainResponse

type QueryStateAndAuthChainResponse 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"`
	// Do all the previous events exist on this roomserver?
	// If some of previous events do not exist this will be false and StateEvents will be empty.
	PrevEventsExist bool `json:"prev_events_exist"`
	StateKnown      bool `json:"state_known"`
	// The state and auth chain events that were requested.
	// The lists will be in an arbitrary order.
	StateEvents     []*gomatrixserverlib.HeaderedEvent `json:"state_events"`
	AuthChainEvents []*gomatrixserverlib.HeaderedEvent `json:"auth_chain_events"`
	// True if the queried event was rejected earlier.
	IsRejected bool `json:"is_rejected"`
}

QueryStateAndAuthChainResponse is a response to QueryStateAndAuthChain

type RemoveRoomAliasRequest

type RemoveRoomAliasRequest struct {
	// ID of the user removing the alias
	UserID string `json:"user_id"`
	// The room alias to remove
	Alias string `json:"alias"`
}

RemoveRoomAliasRequest is a request to RemoveRoomAlias

type RemoveRoomAliasResponse

type RemoveRoomAliasResponse struct {
	// Did the alias exist before?
	Found bool `json:"found"`
	// Did we remove it?
	Removed bool `json:"removed"`
}

RemoveRoomAliasResponse is a response to RemoveRoomAlias

type RoomserverInternalAPI

type RoomserverInternalAPI interface {
	SyncRoomserverAPI
	AppserviceRoomserverAPI
	ClientRoomserverAPI
	UserRoomserverAPI
	FederationRoomserverAPI

	// needed to avoid chicken and egg scenario when setting up the
	// interdependencies between the roomserver and other input APIs
	SetFederationAPI(fsAPI fsAPI.RoomserverFederationAPI, keyRing *gomatrixserverlib.KeyRing)
	SetAppserviceAPI(asAPI asAPI.AppServiceInternalAPI)
	SetUserAPI(userAPI userapi.RoomserverUserAPI)

	// QueryAuthChain returns the entire auth chain for the event IDs given.
	// The response includes the events in the request.
	// Omits without error for any missing auth events. There will be no duplicates.
	// Used in MSC2836.
	QueryAuthChain(
		ctx context.Context,
		req *QueryAuthChainRequest,
		res *QueryAuthChainResponse,
	) error
}

RoomserverInputAPI is used to write events to the room server.

type RoomserverInternalAPITrace

type RoomserverInternalAPITrace struct {
	Impl RoomserverInternalAPI
}

RoomserverInternalAPITrace wraps a RoomserverInternalAPI and logs the complete request/response/error

func (*RoomserverInternalAPITrace) GetAliasesForRoomID

func (*RoomserverInternalAPITrace) GetRoomIDForAlias

func (*RoomserverInternalAPITrace) InputRoomEvents

func (*RoomserverInternalAPITrace) PerformAdminDownloadState added in v0.10.5

func (*RoomserverInternalAPITrace) PerformAdminEvacuateRoom added in v0.8.3

func (*RoomserverInternalAPITrace) PerformAdminEvacuateUser added in v0.8.9

func (*RoomserverInternalAPITrace) PerformBackfill

func (*RoomserverInternalAPITrace) PerformForget added in v0.3.0

func (*RoomserverInternalAPITrace) PerformInboundPeek added in v0.3.7

func (*RoomserverInternalAPITrace) PerformInvite

func (*RoomserverInternalAPITrace) PerformJoin

func (*RoomserverInternalAPITrace) PerformLeave

func (*RoomserverInternalAPITrace) PerformPeek

func (*RoomserverInternalAPITrace) PerformPublish

func (*RoomserverInternalAPITrace) PerformRoomUpgrade added in v0.8.0

func (*RoomserverInternalAPITrace) PerformUnpeek added in v0.3.3

func (*RoomserverInternalAPITrace) QueryAuthChain added in v0.3.3

func (t *RoomserverInternalAPITrace) QueryAuthChain(
	ctx context.Context,
	request *QueryAuthChainRequest,
	response *QueryAuthChainResponse,
) error

func (*RoomserverInternalAPITrace) QueryBulkStateContent

QueryBulkStateContent does a bulk query for state event content in the given rooms.

func (*RoomserverInternalAPITrace) QueryCurrentState

func (*RoomserverInternalAPITrace) QueryEventsByID

func (*RoomserverInternalAPITrace) QueryKnownUsers

QueryKnownUsers returns a list of users that we know about from our joined rooms.

func (*RoomserverInternalAPITrace) QueryLatestEventsAndState

func (*RoomserverInternalAPITrace) QueryMembershipAtEvent added in v0.9.2

func (*RoomserverInternalAPITrace) QueryMembershipForUser

func (*RoomserverInternalAPITrace) QueryMembershipsForRoom

func (*RoomserverInternalAPITrace) QueryMissingEvents

func (*RoomserverInternalAPITrace) QueryPublishedRooms

func (*RoomserverInternalAPITrace) QueryRestrictedJoinAllowed added in v0.8.6

func (*RoomserverInternalAPITrace) QueryRoomVersionCapabilities

func (*RoomserverInternalAPITrace) QueryRoomVersionForRoom

func (*RoomserverInternalAPITrace) QueryRoomsForUser

QueryRoomsForUser retrieves a list of room IDs matching the given query.

func (*RoomserverInternalAPITrace) QueryServerAllowedToSeeEvent

func (*RoomserverInternalAPITrace) QueryServerBannedFromRoom

QueryServerBannedFromRoom returns whether a server is banned from a room by server ACLs.

func (*RoomserverInternalAPITrace) QueryServerJoinedToRoom

func (*RoomserverInternalAPITrace) QuerySharedUsers

QuerySharedUsers returns a list of users who share at least 1 room in common with the given user.

func (*RoomserverInternalAPITrace) QueryStateAfterEvents

func (*RoomserverInternalAPITrace) QueryStateAndAuthChain

func (*RoomserverInternalAPITrace) RemoveRoomAlias

func (*RoomserverInternalAPITrace) SetAppserviceAPI added in v0.3.4

func (t *RoomserverInternalAPITrace) SetAppserviceAPI(asAPI asAPI.AppServiceInternalAPI)

func (*RoomserverInternalAPITrace) SetFederationAPI added in v0.6.0

func (*RoomserverInternalAPITrace) SetRoomAlias

func (*RoomserverInternalAPITrace) SetUserAPI added in v0.6.4

func (t *RoomserverInternalAPITrace) SetUserAPI(userAPI userapi.RoomserverUserAPI)

type SetRoomAliasRequest

type SetRoomAliasRequest struct {
	// ID of the user setting the alias
	UserID string `json:"user_id"`
	// New alias for the room
	Alias string `json:"alias"`
	// The room ID the alias is referring to
	RoomID string `json:"room_id"`
}

SetRoomAliasRequest is a request to SetRoomAlias

type SetRoomAliasResponse

type SetRoomAliasResponse struct {
	// Does the alias already refer to a room?
	AliasExists bool `json:"alias_exists"`
}

SetRoomAliasResponse is a response to SetRoomAlias

type SyncRoomserverAPI added in v0.8.3

type SyncRoomserverAPI interface {
	QueryLatestEventsAndStateAPI
	QueryBulkStateContentAPI
	// QuerySharedUsers returns a list of users who share at least 1 room in common with the given user.
	QuerySharedUsers(ctx context.Context, req *QuerySharedUsersRequest, res *QuerySharedUsersResponse) error
	// Query a list of events by event ID.
	QueryEventsByID(
		ctx context.Context,
		req *QueryEventsByIDRequest,
		res *QueryEventsByIDResponse,
	) error
	// Query the membership event for an user for a room.
	QueryMembershipForUser(
		ctx context.Context,
		req *QueryMembershipForUserRequest,
		res *QueryMembershipForUserResponse,
	) error

	// Query the state after a list of events in a room from the room server.
	QueryStateAfterEvents(
		ctx context.Context,
		req *QueryStateAfterEventsRequest,
		res *QueryStateAfterEventsResponse,
	) error

	// Query a given amount (or less) of events prior to a given set of events.
	PerformBackfill(
		ctx context.Context,
		req *PerformBackfillRequest,
		res *PerformBackfillResponse,
	) error

	// QueryMembershipAtEvent queries the memberships at the given events.
	// Returns a map from eventID to a slice of gomatrixserverlib.HeaderedEvent.
	QueryMembershipAtEvent(
		ctx context.Context,
		request *QueryMembershipAtEventRequest,
		response *QueryMembershipAtEventResponse,
	) error
}

API functions required by the syncapi

type TransactionID

type TransactionID struct {
	SessionID     int64  `json:"session_id"`
	TransactionID string `json:"id"`
}

TransactionID contains the transaction ID sent by a client when sending an event, along with the ID of the client session.

type UserRoomserverAPI added in v0.8.3

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL