api

package
v0.13.8 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2024 License: Apache-2.0 Imports: 18 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, roomID, eventID string) *types.HeaderedEvent

GetEvent returns the event or nil, even on errors.

func GetStateEvent

func GetStateEvent(ctx context.Context, rsAPI QueryEventsAPI, roomID string, tuple gomatrixserverlib.StateKeyTuple) *types.HeaderedEvent

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

func IsServerBannedFromRoom

func IsServerBannedFromRoom(ctx context.Context, rsAPI FederationRoomserverAPI, roomID string, serverName spec.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) ([]fclient.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,
	virtualHost spec.ServerName, kind Kind,
	state gomatrixserverlib.StateResponse, event *types.HeaderedEvent,
	origin spec.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 []*types.HeaderedEvent,
	virtualHost, origin spec.ServerName,
	sendAsServer spec.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,
	virtualHost spec.ServerName,
	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 {
	QuerySenderIDAPI
	// QueryEventsByID queries a list of events by event ID for one room. If no room is specified, it will try to determine
	// which room to use by querying the first events roomID.
	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
	QuerySenderIDAPI
	UserRoomPrivateKeyCreator
	QueryRoomHierarchyAPI
	DefaultRoomVersionAPI

	QueryMembershipForUser(ctx context.Context, req *QueryMembershipForUserRequest, res *QueryMembershipForUserResponse) error
	QueryMembershipsForRoom(ctx context.Context, req *QueryMembershipsForRoomRequest, res *QueryMembershipsForRoomResponse) error
	QueryRoomsForUser(ctx context.Context, userID spec.UserID, desiredMembership string) ([]spec.RoomID, 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, roomID string) (gomatrixserverlib.RoomVersion, error)
	QueryPublishedRooms(ctx context.Context, req *QueryPublishedRoomsRequest, res *QueryPublishedRoomsResponse) error

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

	PerformCreateRoom(ctx context.Context, userID spec.UserID, roomID spec.RoomID, createRequest *PerformCreateRoomRequest) (string, *util.JSONResponse)
	// PerformRoomUpgrade upgrades a room to a newer version
	PerformRoomUpgrade(ctx context.Context, roomID string, userID spec.UserID, roomVersion gomatrixserverlib.RoomVersion) (newRoomID string, err error)
	PerformAdminEvacuateRoom(ctx context.Context, roomID string) (affected []string, err error)
	PerformAdminEvacuateUser(ctx context.Context, userID string) (affected []string, err error)
	PerformAdminPurgeRoom(ctx context.Context, roomID string) error
	PerformAdminDownloadState(ctx context.Context, roomID, userID string, serverName spec.ServerName) error
	PerformPeek(ctx context.Context, req *PerformPeekRequest) (roomID string, err error)
	PerformUnpeek(ctx context.Context, roomID, userID, deviceID string) error
	PerformInvite(ctx context.Context, req *PerformInviteRequest) error
	PerformJoin(ctx context.Context, req *PerformJoinRequest) (roomID string, joinedVia spec.ServerName, err error)
	PerformLeave(ctx context.Context, req *PerformLeaveRequest, res *PerformLeaveResponse) error
	PerformPublish(ctx context.Context, req *PerformPublishRequest) error
	// PerformForget forgets a rooms history for a specific user
	PerformForget(ctx context.Context, req *PerformForgetRequest, resp *PerformForgetResponse) error

	// Sets a room alias, as provided sender, pointing to the provided room ID.
	//
	// If err is nil, then the returned boolean indicates if the alias is already in use.
	// If true, then the alias has not been set to the provided room, as it already in use.
	SetRoomAlias(ctx context.Context, senderID spec.SenderID, roomID spec.RoomID, alias string) (aliasAlreadyExists bool, err error)

	//RemoveRoomAlias(ctx context.Context, req *RemoveRoomAliasRequest, res *RemoveRoomAliasResponse) error
	// Removes a room alias, as provided sender.
	//
	// Returns whether the alias was found, whether it was removed, and an error (if any occurred)
	RemoveRoomAlias(ctx context.Context, senderID spec.SenderID, alias string) (aliasFound bool, aliasRemoved bool, err error)

	SigningIdentityFor(ctx context.Context, roomID spec.RoomID, senderID spec.UserID) (fclient.SigningIdentity, error)

	InsertReportedEvent(
		ctx context.Context,
		roomID, eventID, reportingUserID, reason string,
		score int64,
	) (int64, error)
	QueryAdminEventReports(ctx context.Context, from, limit uint64, backwards bool, userID, roomID string) ([]QueryAdminEventReportsResponse, int64, error)
	QueryAdminEventReport(ctx context.Context, reportID uint64) (QueryAdminEventReportResponse, error)
	PerformAdminDeleteEventReport(ctx context.Context, reportID uint64) error
}

type DefaultRoomVersionAPI added in v0.13.2

type DefaultRoomVersionAPI interface {
	// Returns the default room version used.
	DefaultRoomVersion() gomatrixserverlib.RoomVersion
}

type ErrInvalidID added in v0.13.0

type ErrInvalidID struct {
	Err error
}

ErrInvalidID is an error returned if the userID is invalid

func (ErrInvalidID) Error added in v0.13.0

func (e ErrInvalidID) Error() string

type ErrNotAllowed added in v0.13.0

type ErrNotAllowed struct {
	Err error
}

ErrNotAllowed is an error returned if the user is not allowed to execute some action (e.g. invite)

func (ErrNotAllowed) Error added in v0.13.0

func (e ErrNotAllowed) Error() string

type ErrRoomUnknownOrNotAllowed added in v0.13.2

type ErrRoomUnknownOrNotAllowed struct {
	Err error
}

ErrRoomUnknownOrNotAllowed is an error return if either the provided room ID does not exist, or points to a room that the requester does not have access to.

func (ErrRoomUnknownOrNotAllowed) Error added in v0.13.2

type FederationRoomserverAPI added in v0.8.3

type FederationRoomserverAPI interface {
	RestrictedJoinAPI
	InputRoomEventsAPI
	QueryLatestEventsAndStateAPI
	QueryBulkStateContentAPI
	QuerySenderIDAPI
	QueryRoomHierarchyAPI
	QueryMembershipAPI
	UserRoomPrivateKeyCreator
	AssignRoomNID(ctx context.Context, roomID spec.RoomID, roomVersion gomatrixserverlib.RoomVersion) (roomNID types.RoomNID, err error)
	SigningIdentityFor(ctx context.Context, roomID spec.RoomID, senderID spec.UserID) (fclient.SigningIdentity, error)
	// QueryServerBannedFromRoom returns whether a server is banned from a room by server ACLs.
	QueryServerBannedFromRoom(ctx context.Context, req *QueryServerBannedFromRoomRequest, res *QueryServerBannedFromRoomResponse) error
	GetRoomIDForAlias(ctx context.Context, req *GetRoomIDForAliasRequest, res *GetRoomIDForAliasResponse) error
	// QueryEventsByID queries a list of events by event ID for one room. If no room is specified, it will try to determine
	// which room to use by querying the first events roomID.
	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
	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, serverName spec.ServerName, eventID string, roomID string) (allowed bool, err error)
	QueryRoomsForUser(ctx context.Context, userID spec.UserID, desiredMembership string) ([]spec.RoomID, error)
	QueryRestrictedJoinAllowed(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (string, error)
	PerformInboundPeek(ctx context.Context, req *PerformInboundPeekRequest, res *PerformInboundPeekResponse) error
	HandleInvite(ctx context.Context, event *types.HeaderedEvent) error

	PerformInvite(ctx context.Context, req *PerformInviteRequest) 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

	IsKnownRoom(ctx context.Context, roomID spec.RoomID) (bool, error)
	StateQuerier() gomatrixserverlib.StateQuerier
}

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 *types.HeaderedEvent `json:"event"`
	// Which server told us about this event.
	Origin spec.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,
	)
}

type InputRoomEventsRequest

type InputRoomEventsRequest struct {
	InputRoomEvents []InputRoomEvent `json:"input_room_events"`
	Asynchronous    bool             `json:"async"`
	VirtualHost     spec.ServerName  `json:"virtual_host"`
}

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 InviteInput added in v0.13.2

type InviteInput struct {
	RoomID     spec.RoomID
	Inviter    spec.UserID
	Invitee    spec.UserID
	Reason     string
	IsDirect   bool
	KeyID      gomatrixserverlib.KeyID
	PrivateKey ed25519.PrivateKey
	EventTime  time.Time
}

type JoinRoomQuerier added in v0.13.0

type JoinRoomQuerier struct {
	Roomserver RestrictedJoinAPI
}

func (*JoinRoomQuerier) CurrentStateEvent added in v0.13.0

func (rq *JoinRoomQuerier) CurrentStateEvent(ctx context.Context, roomID spec.RoomID, eventType string, stateKey string) (gomatrixserverlib.PDU, error)

func (*JoinRoomQuerier) InvitePending added in v0.13.0

func (rq *JoinRoomQuerier) InvitePending(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (bool, error)

func (*JoinRoomQuerier) RestrictedRoomJoinInfo added in v0.13.0

func (rq *JoinRoomQuerier) RestrictedRoomJoinInfo(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID, localServerName spec.ServerName) (*gomatrixserverlib.RestrictedRoomJoinInfo, error)

type KeyserverRoomserverAPI added in v0.10.9

type KeyserverRoomserverAPI interface {
	QueryLeftUsers(ctx context.Context, req *QueryLeftUsersRequest, res *QueryLeftUsersResponse) 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 MembershipQuerier added in v0.13.0

type MembershipQuerier struct {
	Roomserver FederationRoomserverAPI
}

func (*MembershipQuerier) CurrentMembership added in v0.13.0

func (mq *MembershipQuerier) CurrentMembership(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (string, error)

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"`
	// The content of the event with type OutputPurgeRoom
	PurgeRoom *OutputPurgeRoom `json:"purge_room,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    spec.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 *types.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 *types.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() ([]*types.HeaderedEvent, []string)

type OutputOldRoomEvent added in v0.2.0

type OutputOldRoomEvent struct {
	// The Event.
	Event             *types.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 OutputPurgeRoom added in v0.11.0

type OutputPurgeRoom struct {
	RoomID string
}

type OutputRedactedEvent

type OutputRedactedEvent struct {
	// The event ID that was redacted
	RedactedEventID string
	// The value of `unsigned.redacted_because` - the redaction event itself
	RedactedBecause *types.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 room ID of the "m.room.member" invite event.
	RoomID string
	// The target sender ID of the "m.room.member" invite event that was retired.
	TargetSenderID spec.SenderID
	// 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"
	// OutputTypePurgeRoom indicates the event is an OutputPurgeRoom
	OutputTypePurgeRoom OutputType = "purge_room"
)

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 spec.ServerName `json:"server_name"`
	// Which virtual host are we doing this for?
	VirtualHost spec.ServerName `json:"virtual_host"`
}

PerformBackfillRequest is a request to PerformBackfill.

func (*PerformBackfillRequest) PrevEventIDs

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

PrevEventIDs returns the prev_event IDs of either 100 backwards extremities or len(r.BackwardsExtremities). Limited to 100, due to Synapse/Dendrite stopping after reaching this limit. (which sounds sane)

type PerformBackfillResponse

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

PerformBackfillResponse is a response to PerformBackfill.

type PerformCreateRoomRequest added in v0.13.0

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
}

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

type PerformInviteRequest

type PerformInviteRequest struct {
	InviteInput     InviteInput
	InviteRoomState []gomatrixserverlib.InviteStrippedState `json:"invite_room_state"`
	SendAsServer    string                                  `json:"send_as_server"`
	TransactionID   *TransactionID                          `json:"transaction_id"`
}

type PerformJoinRequest

type PerformJoinRequest struct {
	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"`
}

type PerformLeaveRequest

type PerformLeaveRequest struct {
	RoomID string
	Leaver spec.UserID
}

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   []spec.ServerName `json:"server_names"`
}

type PerformPublishRequest

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

type QueryAdminEventReportResponse added in v0.13.7

type QueryAdminEventReportResponse struct {
	QueryAdminEventReportsResponse
	EventJSON json.RawMessage `json:"event_json"`
}

type QueryAdminEventReportsResponse added in v0.13.7

type QueryAdminEventReportsResponse struct {
	ID               int64                  `json:"id"`
	Score            int64                  `json:"score"`
	EventNID         types.EventNID         `json:"-"` // only used to query the state
	RoomNID          types.RoomNID          `json:"-"` // only used to query the state
	ReportingUserNID types.EventStateKeyNID `json:"-"` // only used in the DB
	SenderNID        types.EventStateKeyNID `json:"-"` // only used in the DB
	RoomID           string                 `json:"room_id"`
	EventID          string                 `json:"event_id"`
	UserID           string                 `json:"user_id"` // the user reporting the event
	Reason           string                 `json:"reason"`
	Sender           string                 `json:"sender"` // the user sending the reported event
	CanonicalAlias   string                 `json:"canonical_alias"`
	RoomName         string                 `json:"name"`
	ReceivedTS       spec.Timestamp         `json:"received_ts"`
}

type QueryAuthChainRequest added in v0.3.3

type QueryAuthChainRequest struct {
	EventIDs []string
}

type QueryAuthChainResponse added in v0.3.3

type QueryAuthChainResponse struct {
	AuthChain []*types.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]*types.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 {
	// QueryEventsByID queries a list of events by event ID for one room. If no room is specified, it will try to determine
	// which room to use by querying the first events roomID.
	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 roomID to query events for. If this is empty, we first try to fetch the roomID from the database
	// as this is needed for further processing/parsing events.
	RoomID string `json:"room_id"`
	// 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 []*types.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 []string `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 []*types.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 QueryLeftUsersRequest added in v0.10.9

type QueryLeftUsersRequest struct {
	StaleDeviceListUsers []string `json:"user_ids"`
}

QueryLeftUsersRequest is a request to calculate users that we (the server) don't share a a room with anymore. This is used to cleanup stale device list entries, where we would otherwise keep on trying to get device lists.

type QueryLeftUsersResponse added in v0.10.9

type QueryLeftUsersResponse struct {
	LeftUsers []string `json:"user_ids"`
}

QueryLeftUsersResponse is the response to QueryLeftUsersRequest.

type QueryMembershipAPI added in v0.13.2

type QueryMembershipAPI interface {
	QueryMembershipForSenderID(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID, res *QueryMembershipForUserResponse) error
	QueryMembershipForUser(ctx context.Context, req *QueryMembershipForUserRequest, res *QueryMembershipForUserResponse) error
	QueryMembershipsForRoom(ctx context.Context, req *QueryMembershipsForRoomRequest, res *QueryMembershipsForRoomResponse) error
	QueryRoomVersionForRoom(ctx context.Context, roomID string) (gomatrixserverlib.RoomVersion, error)

	// QueryMembershipAtEvent queries the memberships at the given events.
	// Returns a map from eventID to *types.HeaderedEvent of membership events.
	QueryMembershipAtEvent(
		ctx context.Context,
		roomID spec.RoomID,
		eventIDs []string,
		senderID spec.SenderID,
	) (map[string]*types.HeaderedEvent, error)
}

type QueryMembershipForUserRequest

type QueryMembershipForUserRequest struct {
	// ID of the room to fetch membership from
	RoomID string
	// ID of the user for whom membership is requested
	UserID spec.UserID
}

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"`
	// The sender ID of the user in the room, if it exists
	SenderID *spec.SenderID
}

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.
	SenderID spec.SenderID `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 []synctypes.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 spec.ServerName `json:"server_name"`
}

QueryMissingEventsRequest is a request to QueryMissingEvents

type QueryMissingEventsResponse

type QueryMissingEventsResponse struct {
	// Missing events, arbritrary order.
	Events []*types.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 QueryRoomHierarchyAPI added in v0.13.2

type QueryRoomHierarchyAPI interface {
	// Traverse the room hierarchy using the provided walker up to the provided limit,
	// returning a new walker which can be used to fetch the next page.
	//
	// If limit is -1, this is treated as no limit, and the entire hierarchy will be traversed.
	//
	// If returned walker is nil, then there are no more rooms left to traverse. This method does not modify the provided walker, so it
	// can be cached.
	QueryNextRoomHierarchyPage(ctx context.Context, walker RoomHierarchyWalker, limit int) (
		hierarchyRooms []fclient.RoomHierarchyRoom,
		inaccessibleRooms []string,
		hierarchyWalker *RoomHierarchyWalker,
		err error,
	)
}

type QueryRoomHierarchyRequest added in v0.13.2

type QueryRoomHierarchyRequest struct {
	SuggestedOnly bool `json:"suggested_only"`
	Limit         int  `json:"limit"`
	MaxDepth      int  `json:"max_depth"`
	From          int  `json:"json"`
}

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 QuerySenderIDAPI added in v0.13.0

type QuerySenderIDAPI interface {
	QuerySenderIDForUser(ctx context.Context, roomID spec.RoomID, userID spec.UserID) (*spec.SenderID, error)
	QueryUserIDForSender(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (*spec.UserID, error)
}

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 spec.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 spec.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 spec.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"`
	// The roomversion if joined to room
	RoomVersion gomatrixserverlib.RoomVersion
}

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 []*types.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     []*types.HeaderedEvent `json:"state_events"`
	AuthChainEvents []*types.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 RestrictedJoinAPI added in v0.13.0

type RestrictedJoinAPI interface {
	CurrentStateEvent(ctx context.Context, roomID spec.RoomID, eventType string, stateKey string) (gomatrixserverlib.PDU, error)
	InvitePending(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID) (bool, error)
	RestrictedRoomJoinInfo(ctx context.Context, roomID spec.RoomID, senderID spec.SenderID, localServerName spec.ServerName) (*gomatrixserverlib.RestrictedRoomJoinInfo, error)
	QueryRoomInfo(ctx context.Context, roomID spec.RoomID) (*types.RoomInfo, error)
	QueryServerJoinedToRoom(ctx context.Context, req *QueryServerJoinedToRoomRequest, res *QueryServerJoinedToRoomResponse) error
	UserJoinedToRoom(ctx context.Context, roomID types.RoomNID, senderID spec.SenderID) (bool, error)
	LocallyJoinedUsers(ctx context.Context, roomVersion gomatrixserverlib.RoomVersion, roomNID types.RoomNID) ([]gomatrixserverlib.PDU, error)
}

type RoomHierarchyWalker added in v0.13.2

type RoomHierarchyWalker struct {
	RootRoomID    spec.RoomID
	Caller        types.DeviceOrServerName
	SuggestedOnly bool
	MaxDepth      int
	Processed     RoomSet
	Unvisited     []RoomHierarchyWalkerQueuedRoom
}

A struct storing the intermediate state of a room hierarchy query for pagination purposes.

Used for implementing space summaries / room hierarchies

Use NewRoomHierarchyWalker to construct this, and QueryNextRoomHierarchyPage on the roomserver API to traverse the room hierarchy.

func NewRoomHierarchyWalker added in v0.13.2

func NewRoomHierarchyWalker(caller types.DeviceOrServerName, roomID spec.RoomID, suggestedOnly bool, maxDepth int) RoomHierarchyWalker

Create a new room hierarchy walker, starting from the provided root room ID.

Use the resulting struct with QueryNextRoomHierarchyPage on the roomserver API to traverse the room hierarchy.

type RoomHierarchyWalkerQueuedRoom added in v0.13.2

type RoomHierarchyWalkerQueuedRoom struct {
	RoomID       spec.RoomID
	ParentRoomID *spec.RoomID
	Depth        int
	Vias         []string // vias to query this room by
}

type RoomSet added in v0.13.2

type RoomSet map[spec.RoomID]struct{}

A set of room IDs.

func NewRoomSet added in v0.13.2

func NewRoomSet() RoomSet

Create a new empty room set.

func (RoomSet) Add added in v0.13.2

func (s RoomSet) Add(val spec.RoomID)

Add a room ID to a room set.

func (RoomSet) Contains added in v0.13.2

func (s RoomSet) Contains(val spec.RoomID) bool

Check if a room ID is in a room set.

func (RoomSet) Copy added in v0.13.2

func (s RoomSet) Copy() RoomSet

type RoomserverInternalAPI

type RoomserverInternalAPI interface {
	SyncRoomserverAPI
	AppserviceRoomserverAPI
	ClientRoomserverAPI
	UserRoomserverAPI
	FederationRoomserverAPI
	QuerySenderIDAPI
	UserRoomPrivateKeyCreator
	DefaultRoomVersionAPI

	// 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

	// RoomsWithACLs returns all room IDs for rooms with ACLs
	RoomsWithACLs(ctx context.Context) ([]string, error)
}

RoomserverInputAPI is used to write events to the room server.

type SyncRoomserverAPI added in v0.8.3

type SyncRoomserverAPI interface {
	QueryLatestEventsAndStateAPI
	QueryBulkStateContentAPI
	QuerySenderIDAPI
	QueryMembershipAPI
	// 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
	// QueryEventsByID queries a list of events by event ID for one room. If no room is specified, it will try to determine
	// which room to use by querying the first events roomID.
	QueryEventsByID(
		ctx context.Context,
		req *QueryEventsByIDRequest,
		res *QueryEventsByIDResponse,
	) 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
}

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 UserRoomPrivateKeyCreator added in v0.13.0

type UserRoomPrivateKeyCreator interface {
	// GetOrCreateUserRoomPrivateKey gets the user room key for the specified user. If no key exists yet, a new one is created.
	GetOrCreateUserRoomPrivateKey(ctx context.Context, userID spec.UserID, roomID spec.RoomID) (ed25519.PrivateKey, error)
	StoreUserRoomPublicKey(ctx context.Context, senderID spec.SenderID, userID spec.UserID, roomID spec.RoomID) error
}

type UserRoomserverAPI added in v0.8.3

type UserRoomserverAPI interface {
	QuerySenderIDAPI
	QueryLatestEventsAndStateAPI
	KeyserverRoomserverAPI
	QueryCurrentState(ctx context.Context, req *QueryCurrentStateRequest, res *QueryCurrentStateResponse) error
	QueryMembershipsForRoom(ctx context.Context, req *QueryMembershipsForRoomRequest, res *QueryMembershipsForRoomResponse) error
	PerformAdminEvacuateUser(ctx context.Context, userID string) (affected []string, err error)
	PerformJoin(ctx context.Context, req *PerformJoinRequest) (roomID string, joinedVia spec.ServerName, err error)
	JoinedUserCount(ctx context.Context, roomID string) (int, error)
}

Jump to

Keyboard shortcuts

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