synctypes

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventFormatClient     = "client"
	EventFormatFederation = "federation"
)

Variables

This section is empty.

Functions

func FromClientStateKey

func FromClientStateKey(roomID spec.RoomID, stateKey string, senderIDQuery spec.SenderIDForUser) (*string, error)

If provided state key is a user ID (state keys beginning with @ are reserved for this purpose) fetch it's associated sender ID and use that instead. Otherwise returns the same state key back.

This function either returns the state key that should be used, or an error

TODO: handle failure cases better (e.g. no sender ID)

func GetUpdatedInviteRoomState

func GetUpdatedInviteRoomState(userIDForSender spec.UserIDForSender, inviteRoomState gjson.Result, event gomatrixserverlib.PDU, roomID spec.RoomID, eventFormat ClientEventFormat) (spec.RawJSON, error)

Types

type ClientEvent

type ClientEvent struct {
	Content        spec.RawJSON   `json:"content"`
	EventID        string         `json:"event_id,omitempty"`         // EventID is omitted on receipt events
	OriginServerTS spec.Timestamp `json:"origin_server_ts,omitempty"` // OriginServerTS is omitted on receipt events
	RoomID         string         `json:"room_id,omitempty"`          // RoomID is omitted on /sync responses
	Sender         string         `json:"sender,omitempty"`           // Sender is omitted on receipt events
	SenderKey      spec.SenderID  `json:"sender_key,omitempty"`       // The SenderKey for events in pseudo ID rooms
	StateKey       *string        `json:"state_key,omitempty"`
	Type           string         `json:"type"`
	Unsigned       spec.RawJSON   `json:"unsigned,omitempty"`
	Redacts        string         `json:"redacts,omitempty"`

	// Only sent to clients when `event_format` == `federation`.
	ClientFederationFields
}

ClientEvent is an event which is fit for consumption by clients, in accordance with the specification.

func ToClientEvent

func ToClientEvent(se gomatrixserverlib.PDU, format ClientEventFormat, userIDForSender spec.UserIDForSender) (*ClientEvent, error)

ToClientEvent converts a single server event to a client event.

func ToClientEventDefault

func ToClientEventDefault(userIDQuery spec.UserIDForSender, event gomatrixserverlib.PDU) ClientEvent

ToClientEventDefault converts a single server event to a client event. It provides default logic for event.SenderID & event.StateKey -> userID conversions.

func ToClientEvents

func ToClientEvents(serverEvs []gomatrixserverlib.PDU, format ClientEventFormat, userIDForSender spec.UserIDForSender) []ClientEvent

ToClientEvents converts server events to client events.

type ClientEventFormat

type ClientEventFormat int
const (
	// FormatAll will include all client event keys
	FormatAll ClientEventFormat = iota
	// FormatSync will include only the event keys required by the /sync API. Notably, this
	// means the 'room_id' will be missing from the events.
	FormatSync
	// FormatSyncFederation will include all event keys normally included in federated events.
	// This allows clients to request federated formatted events via the /sync API.
	FormatSyncFederation
)

type ClientFederationFields

type ClientFederationFields struct {
	Depth      int64        `json:"depth,omitempty"`
	PrevEvents []string     `json:"prev_events,omitempty"`
	AuthEvents []string     `json:"auth_events,omitempty"`
	Signatures spec.RawJSON `json:"signatures,omitempty"`
	Hashes     spec.RawJSON `json:"hashes,omitempty"`
}

ClientFederationFields extends a ClientEvent to contain the additional fields present in a federation event. Used when the client requests `event_format` of type `federation`.

type EventFilter

type EventFilter struct {
	Limit      int       `json:"limit,omitempty"`
	NotSenders *[]string `json:"not_senders,omitempty"`
	NotTypes   *[]string `json:"not_types,omitempty"`
	Senders    *[]string `json:"senders,omitempty"`
	Types      *[]string `json:"types,omitempty"`
}

EventFilter is used to define filtering rules for events

func DefaultEventFilter

func DefaultEventFilter() EventFilter

DefaultEventFilter returns the default event filter used by the Matrix server if no filter is provided in the request

type Filter

type Filter struct {
	EventFields []string    `json:"event_fields,omitempty"`
	EventFormat string      `json:"event_format,omitempty"`
	Presence    EventFilter `json:"presence,omitempty"`
	AccountData EventFilter `json:"account_data,omitempty"`
	Room        RoomFilter  `json:"room,omitempty"`
}

Filter is used by clients to specify how the server should filter responses to e.g. sync requests Specified by: https://spec.matrix.org/v1.6/client-server-api/#filtering

func DefaultFilter

func DefaultFilter() Filter

DefaultFilter returns the default filter used by the Matrix server if no filter is provided in the request

func (*Filter) Validate

func (filter *Filter) Validate() error

Validate checks if the filter contains valid property values

type InviteRoomStateEvent

type InviteRoomStateEvent struct {
	Content  spec.RawJSON `json:"content"`
	SenderID string       `json:"sender"`
	StateKey *string      `json:"state_key"`
	Type     string       `json:"type"`
}

type PrevEventRef

type PrevEventRef struct {
	PrevContent   json.RawMessage `json:"prev_content"`
	ReplacesState string          `json:"replaces_state"`
	PrevSenderID  string          `json:"prev_sender"`
}

PrevEventRef represents a reference to a previous event in a state event upgrade

type RoomEventFilter

type RoomEventFilter struct {
	Limit                     int       `json:"limit,omitempty"`
	NotSenders                *[]string `json:"not_senders,omitempty"`
	NotTypes                  *[]string `json:"not_types,omitempty"`
	Senders                   *[]string `json:"senders,omitempty"`
	Types                     *[]string `json:"types,omitempty"`
	LazyLoadMembers           bool      `json:"lazy_load_members,omitempty"`
	IncludeRedundantMembers   bool      `json:"include_redundant_members,omitempty"`
	NotRooms                  *[]string `json:"not_rooms,omitempty"`
	Rooms                     *[]string `json:"rooms,omitempty"`
	UnreadThreadNotifications bool      `json:"unread_thread_notifications,omitempty"`
	ContainsURL               *bool     `json:"contains_url,omitempty"`
}

RoomEventFilter is used to define filtering rules for events in rooms

func DefaultRoomEventFilter

func DefaultRoomEventFilter() RoomEventFilter

DefaultRoomEventFilter returns the default room event filter used by the Matrix server if no filter is provided in the request

type RoomFilter

type RoomFilter struct {
	NotRooms     *[]string       `json:"not_rooms,omitempty"`
	Rooms        *[]string       `json:"rooms,omitempty"`
	Ephemeral    RoomEventFilter `json:"ephemeral,omitempty"`
	IncludeLeave bool            `json:"include_leave,omitempty"`
	State        StateFilter     `json:"state,omitempty"`
	Timeline     RoomEventFilter `json:"timeline,omitempty"`
	AccountData  RoomEventFilter `json:"account_data,omitempty"`
}

RoomFilter is used to define filtering rules for room-related events

type StateFilter

type StateFilter struct {
	NotSenders                *[]string `json:"not_senders,omitempty"`
	NotTypes                  *[]string `json:"not_types,omitempty"`
	Senders                   *[]string `json:"senders,omitempty"`
	Types                     *[]string `json:"types,omitempty"`
	LazyLoadMembers           bool      `json:"lazy_load_members,omitempty"`
	IncludeRedundantMembers   bool      `json:"include_redundant_members,omitempty"`
	NotRooms                  *[]string `json:"not_rooms,omitempty"`
	Rooms                     *[]string `json:"rooms,omitempty"`
	Limit                     int       `json:"limit,omitempty"`
	UnreadThreadNotifications bool      `json:"unread_thread_notifications,omitempty"`
	ContainsURL               *bool     `json:"contains_url,omitempty"`
}

StateFilter is used to define filtering rules for state events

func DefaultStateFilter

func DefaultStateFilter() StateFilter

DefaultStateFilter returns the default state event filter used by the Matrix server if no filter is provided in the request

Jump to

Keyboard shortcuts

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