Documentation ¶
Index ¶
- Variables
- type ClientEvents
- type DeviceLists
- type IgnoredUsers
- type InviteResponse
- type JoinResponse
- type LeaveResponse
- type OutputReceiptEvent
- type OutputSendToDeviceEvent
- type Peek
- type PeekingDevice
- type Presence
- type PresenceClientResponse
- type PresenceInternal
- type Range
- type RecentEvents
- type RelationEntry
- type Response
- type RoomsResponse
- type SendToDeviceEvent
- type StateDelta
- type StreamEvent
- type StreamPosition
- type StreamingToken
- func (t *StreamingToken) ApplyUpdates(other StreamingToken)
- func (t *StreamingToken) IsAfter(other StreamingToken) bool
- func (t *StreamingToken) IsEmpty() bool
- func (s StreamingToken) MarshalText() ([]byte, error)
- func (t StreamingToken) String() string
- func (s *StreamingToken) UnmarshalText(text []byte) (err error)
- func (t *StreamingToken) WithUpdates(other StreamingToken) StreamingToken
- type Summary
- type SyncRequest
- type SyncTokenType
- type Timeline
- type ToDeviceResponse
- type TopologyToken
- type UnreadNotifications
Constants ¶
This section is empty.
Variables ¶
var ( // This error is returned when parsing sync tokens if the token is invalid. Callers can use this // error to detect whether to 400 or 401 the client. It is recommended to 401 them to force a // logout. ErrMalformedSyncToken = errors.New("malformed sync token") )
Functions ¶
This section is empty.
Types ¶
type ClientEvents ¶ added in v0.10.2
type ClientEvents struct {
Events []synctypes.ClientEvent `json:"events,omitempty"`
}
type DeviceLists ¶ added in v0.10.2
type IgnoredUsers ¶ added in v0.8.0
type IgnoredUsers struct {
List map[string]interface{} `json:"ignored_users"`
}
type InviteResponse ¶
type InviteResponse struct { InviteState struct { Events []json.RawMessage `json:"events"` } `json:"invite_state"` }
InviteResponse represents a /sync response for a room which is under the 'invite' key.
func NewInviteResponse ¶
func NewInviteResponse(ctx context.Context, rsAPI api.QuerySenderIDAPI, event *types.HeaderedEvent, eventFormat synctypes.ClientEventFormat) (*InviteResponse, error)
NewInviteResponse creates an empty response with initialised arrays.
type JoinResponse ¶
type JoinResponse struct { Summary *Summary `json:"summary,omitempty"` State *ClientEvents `json:"state,omitempty"` Timeline *Timeline `json:"timeline,omitempty"` Ephemeral *ClientEvents `json:"ephemeral,omitempty"` AccountData *ClientEvents `json:"account_data,omitempty"` *UnreadNotifications `json:"unread_notifications,omitempty"` }
JoinResponse represents a /sync response for a room which is under the 'join' or 'peek' key.
func NewJoinResponse ¶
func NewJoinResponse() *JoinResponse
NewJoinResponse creates an empty response with initialised arrays.
func (JoinResponse) MarshalJSON ¶ added in v0.10.2
func (jr JoinResponse) MarshalJSON() ([]byte, error)
type LeaveResponse ¶
type LeaveResponse struct { State *ClientEvents `json:"state,omitempty"` Timeline *Timeline `json:"timeline,omitempty"` }
LeaveResponse represents a /sync response for a room which is under the 'leave' key.
func NewLeaveResponse ¶
func NewLeaveResponse() *LeaveResponse
NewLeaveResponse creates an empty response with initialised arrays.
func (LeaveResponse) MarshalJSON ¶ added in v0.10.2
func (lr LeaveResponse) MarshalJSON() ([]byte, error)
type OutputReceiptEvent ¶ added in v0.8.0
type OutputReceiptEvent struct { UserID string `json:"user_id"` RoomID string `json:"room_id"` EventID string `json:"event_id"` Type string `json:"type"` Timestamp spec.Timestamp `json:"timestamp"` }
OutputReceiptEvent is an entry in the receipt output kafka log
type OutputSendToDeviceEvent ¶ added in v0.8.0
type OutputSendToDeviceEvent struct { UserID string `json:"user_id"` DeviceID string `json:"device_id"` gomatrixserverlib.SendToDeviceEvent }
OutputSendToDeviceEvent is an entry in the send-to-device output kafka log. This contains the full event content, along with the user ID and device ID to which it is destined.
type PeekingDevice ¶
type Presence ¶ added in v0.8.0
type Presence uint8
func PresenceFromString ¶ added in v0.8.0
PresenceFromString returns the integer representation of the given input presence. Returns false for ok, if input is not a valid presence value.
type PresenceClientResponse ¶ added in v0.8.0
type PresenceInternal ¶ added in v0.8.0
type PresenceInternal struct { ClientFields PresenceClientResponse StreamPos StreamPosition `json:"-"` UserID string `json:"-"` LastActiveTS spec.Timestamp `json:"-"` Presence Presence `json:"-"` }
func (*PresenceInternal) CurrentlyActive ¶ added in v0.8.0
func (p *PresenceInternal) CurrentlyActive() bool
CurrentlyActive returns the current active state.
func (*PresenceInternal) Equals ¶ added in v0.8.0
func (p1 *PresenceInternal) Equals(p2 *PresenceInternal) bool
Equals compares p1 with p2.
func (*PresenceInternal) LastActiveAgo ¶ added in v0.8.0
func (p *PresenceInternal) LastActiveAgo() int64
LastActiveAgo returns the time since the LastActiveTS in milliseconds.
type Range ¶
type Range struct { // From is the position the client has already received. From StreamPosition // To is the position the client is going towards. To StreamPosition // True if the client is going backwards Backwards bool }
Range represents a range between two stream positions.
func (*Range) High ¶
func (r *Range) High() StreamPosition
High returns the high number of the range This represents the position the client is going towards and hence is inclusive.
func (*Range) Low ¶
func (r *Range) Low() StreamPosition
Low returns the low number of the range. This represents the position the client already has and hence is exclusive.
type RecentEvents ¶ added in v0.11.1
type RecentEvents struct { Limited bool Events []StreamEvent }
type RelationEntry ¶ added in v0.10.3
type RelationEntry struct { Position StreamPosition EventID string }
type Response ¶
type Response struct { NextBatch StreamingToken `json:"next_batch"` AccountData *ClientEvents `json:"account_data,omitempty"` Presence *ClientEvents `json:"presence,omitempty"` Rooms *RoomsResponse `json:"rooms,omitempty"` ToDevice *ToDeviceResponse `json:"to_device,omitempty"` DeviceLists *DeviceLists `json:"device_lists,omitempty"` DeviceListsOTKCount map[string]int `json:"device_one_time_keys_count,omitempty"` }
Response represents a /sync API response. See https://matrix.org/docs/spec/client_server/r0.2.0.html#get-matrix-client-r0-sync
func NewResponse ¶
func NewResponse() *Response
NewResponse creates an empty response with initialised maps.
func (*Response) HasUpdates ¶ added in v0.8.6
func (*Response) IsEmpty ¶
IsEmpty returns true if the response is empty, i.e. used to decided whether to return the response immediately to the client or to wait for more data.
func (Response) MarshalJSON ¶ added in v0.10.2
type RoomsResponse ¶ added in v0.10.2
type RoomsResponse struct { Join map[string]*JoinResponse `json:"join,omitempty"` Peek map[string]*JoinResponse `json:"peek,omitempty"` Invite map[string]*InviteResponse `json:"invite,omitempty"` Leave map[string]*LeaveResponse `json:"leave,omitempty"` }
type SendToDeviceEvent ¶
type SendToDeviceEvent struct { gomatrixserverlib.SendToDeviceEvent ID StreamPosition UserID string DeviceID string }
type StateDelta ¶ added in v0.3.5
type StateDelta struct { RoomID string StateEvents []*types.HeaderedEvent NewlyJoined bool Membership string // The PDU stream position of the latest membership event for this user, if applicable. // Can be 0 if there is no membership event in this delta. MembershipPos StreamPosition }
type StreamEvent ¶
type StreamEvent struct { *types.HeaderedEvent StreamPosition StreamPosition TransactionID *api.TransactionID ExcludeFromSync bool }
StreamEvent is the same as gomatrixserverlib.Event but also has the PDU stream position for this event.
type StreamPosition ¶
type StreamPosition int64
StreamPosition represents the offset in the sync stream a client is at.
func NewStreamPositionFromString ¶ added in v0.10.3
func NewStreamPositionFromString(s string) (StreamPosition, error)
type StreamingToken ¶
type StreamingToken struct { PDUPosition StreamPosition TypingPosition StreamPosition ReceiptPosition StreamPosition SendToDevicePosition StreamPosition InvitePosition StreamPosition AccountDataPosition StreamPosition DeviceListPosition StreamPosition NotificationDataPosition StreamPosition PresencePosition StreamPosition }
func NewStreamTokenFromString ¶
func NewStreamTokenFromString(tok string) (token StreamingToken, err error)
func (*StreamingToken) ApplyUpdates ¶ added in v0.3.4
func (t *StreamingToken) ApplyUpdates(other StreamingToken)
ApplyUpdates applies any changes from the supplied StreamingToken. If the supplied streaming token contains any positions that are not 0, they are considered updates and will overwrite the value in the token.
func (*StreamingToken) IsAfter ¶
func (t *StreamingToken) IsAfter(other StreamingToken) bool
IsAfter returns true if ANY position in this token is greater than `other`.
func (*StreamingToken) IsEmpty ¶ added in v0.3.4
func (t *StreamingToken) IsEmpty() bool
func (StreamingToken) MarshalText ¶ added in v0.3.4
func (s StreamingToken) MarshalText() ([]byte, error)
This will be used as a fallback by json.Marshal.
func (StreamingToken) String ¶
func (t StreamingToken) String() string
func (*StreamingToken) UnmarshalText ¶ added in v0.3.4
func (s *StreamingToken) UnmarshalText(text []byte) (err error)
This will be used as a fallback by json.Unmarshal.
func (*StreamingToken) WithUpdates ¶
func (t *StreamingToken) WithUpdates(other StreamingToken) StreamingToken
WithUpdates returns a copy of the StreamingToken with updates applied from another StreamingToken. If the latter StreamingToken contains a field that is not 0, it is considered an update, and its value will replace the corresponding value in the StreamingToken on which WithUpdates is called. If the other token has a log, they will replace any existing log on this token.
type SyncRequest ¶ added in v0.3.5
type SyncRequest struct { Context context.Context Log *logrus.Entry Device *userapi.Device Response *Response Filter synctypes.Filter Since StreamingToken Timeout time.Duration WantFullState bool // Updated by the PDU stream. Rooms map[string]string // Updated by the PDU stream. MembershipChanges map[string]struct{} // Updated by the PDU stream. IgnoredUsers IgnoredUsers }
func (*SyncRequest) IsRoomPresent ¶ added in v0.8.2
func (r *SyncRequest) IsRoomPresent(roomID string) bool
type SyncTokenType ¶
type SyncTokenType string
SyncTokenType represents the type of a sync token. It can be either "s" (representing a position in the whole stream of events) or "t" (representing a position in a room's topology/depth).
const ( // SyncTokenTypeStream represents a position in the server's whole // stream of events SyncTokenTypeStream SyncTokenType = "s" // SyncTokenTypeTopology represents a position in a room's topology. SyncTokenTypeTopology SyncTokenType = "t" )
type Timeline ¶ added in v0.10.2
type Timeline struct { Events []synctypes.ClientEvent `json:"events"` Limited bool `json:"limited"` PrevBatch *TopologyToken `json:"prev_batch,omitempty"` }
type ToDeviceResponse ¶ added in v0.10.2
type ToDeviceResponse struct {
Events []gomatrixserverlib.SendToDeviceEvent `json:"events,omitempty"`
}
type TopologyToken ¶
type TopologyToken struct { Depth StreamPosition PDUPosition StreamPosition }
func NewTopologyTokenFromString ¶
func NewTopologyTokenFromString(tok string) (token TopologyToken, err error)
func (*TopologyToken) Decrement ¶
func (t *TopologyToken) Decrement()
Decrement the topology token to one event earlier.
func (TopologyToken) MarshalText ¶ added in v0.3.4
func (t TopologyToken) MarshalText() ([]byte, error)
This will be used as a fallback by json.Marshal.
func (*TopologyToken) StreamToken ¶
func (t *TopologyToken) StreamToken() StreamingToken
func (TopologyToken) String ¶
func (t TopologyToken) String() string
func (*TopologyToken) UnmarshalText ¶ added in v0.3.4
func (t *TopologyToken) UnmarshalText(text []byte) (err error)
This will be used as a fallback by json.Unmarshal.