Documentation ¶
Index ¶
- func PushNotifyMessage(ruleset matrix.PushRuleset, message *RoomMessageEvent) (matrix.PushRule, bool)
- func Register(eventType Type, p func(RawEvent, json.RawMessage) (Event, error))
- func RegisterDefault(eventType Type, p func(json.RawMessage) (Event, error))
- type AudioInfo
- type CallAnswerEvent
- type CallCandidatesEvent
- type CallHangupEvent
- type CallHangupReason
- type CallInviteEvent
- type DirectEvent
- type Event
- type EventInfo
- type FileInfo
- type Filter
- type GlobalFilter
- type GuestAccess
- type HistoryVisibility
- type ImageInfo
- type JoinRule
- type LocationInfo
- type MemberType
- type MessageFormat
- type MessageType
- type Partial
- type PresenceEvent
- type PushRulesEvent
- type RawEvent
- type Receipt
- type ReceiptEvent
- type RoomAvatarEvent
- type RoomCanonicalAliasEvent
- type RoomCreateEvent
- type RoomEvent
- type RoomEventFilter
- type RoomEventInfo
- type RoomFilter
- type RoomGuestAccessEvent
- type RoomHistoryVisibilityEvent
- type RoomJoinRulesEvent
- type RoomMemberEvent
- type RoomMessageEvent
- func (e RoomMessageEvent) AudioInfo() (AudioInfo, error)
- func (e RoomMessageEvent) FileInfo() (FileInfo, error)
- func (e RoomMessageEvent) ImageInfo() (ImageInfo, error)
- func (e *RoomMessageEvent) InReplyTo() matrix.EventID
- func (e RoomMessageEvent) LocationInfo() (LocationInfo, error)
- func (e RoomMessageEvent) StrippedBody() string
- func (e RoomMessageEvent) VideoInfo() (VideoInfo, error)
- type RoomNameEvent
- type RoomPinnedEvent
- type RoomPowerLevelsEvent
- type RoomRedactionEvent
- type RoomTombstoneEvent
- type RoomTopicEvent
- type StateEvent
- type StateEventInfo
- type StateFilter
- type StrippedEvent
- type TagEvent
- type ThumbnailInfo
- type Type
- type TypingEvent
- type UnknownEventTypeError
- type UnsignedData
- type VideoInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PushNotifyMessage ¶
func PushNotifyMessage(ruleset matrix.PushRuleset, message *RoomMessageEvent) (matrix.PushRule, bool)
PushNotifyMessage returns true if the message should be notified by the ruleset. Currently, only the message body is matched.
func Register ¶
Register registers a parser for the provided event type. The parser is passed the full raw event and its content field.
func RegisterDefault ¶
func RegisterDefault(eventType Type, p func(json.RawMessage) (Event, error))
RegisterDefault registers a parser for the provided event type. It automatically fills in the applicable EventInfo and passes only the content to the parser function.
Types ¶
type AudioInfo ¶
type AudioInfo struct { Duration int // Duration of audio in millisecond. MimeType string // MIME type of audio. Size int // Size in bytes. }
AudioInfo stores the info of an audio.
type CallAnswerEvent ¶
type CallAnswerEvent struct { RoomEventInfo `json:"-"` CallID string `json:"call_id"` Version int `json:"int"` Answer struct { Type string `json:"type"` // Must be "answer". SDP string `json:"sdp"` // Session Description Protocol } `json:"answer"` }
CallAnswerEvent is a message event where a callee wishes to answer the call.
type CallCandidatesEvent ¶
type CallCandidatesEvent struct { RoomEventInfo `json:"-"` CallID string `json:"call_id"` Version int `json:"version"` // Currently always 0. Candidates []struct { SDPMediaType string `json:"sdpMid"` SDPMediaLineIndex int `json:"sdpMLineIndex"` Candidate string `json:"candidate"` } `json:"candidates"` }
CallCandidatesEvent is a message event where additional ICE candidates are provided to foster communication.
type CallHangupEvent ¶
type CallHangupEvent struct { RoomEventInfo `json:"-"` CallID string `json:"call_id"` Version int `json:"version"` // Currently always 0. Reason CallHangupReason `json:"reason"` }
CallHangupEvent is a message event where the call is ended. This can be sent to hang up a call or to reject a call.
type CallHangupReason ¶
type CallHangupReason string
CallHangupReason is the reason we hung up.
const ( CallHangupNormal CallHangupReason = "" CallHangupICEFailed CallHangupReason = "ice_failed" // ICE negotiation failed. CallHangupInviteTimeout CallHangupReason = "invite_timeout" )
Possible reasons to hang up.
type CallInviteEvent ¶
type CallInviteEvent struct { RoomEventInfo `json:"-"` CallID string `json:"call_id"` Version int `json:"version"` // Currently always 0. Lifetime int `json:"lifetime"` // Milliseconds the offer is valid for. Offer struct { Type string `json:"type"` // Must be "offer". SDP string `json:"sdp"` // Session Description Protocol } `json:"offer"` }
CallInviteEvent is a message event where someone is inviting to establish a call.
type DirectEvent ¶
DirectEvent is an event that lists all the DM channels the user is in. It is saved in AccountData.
func (DirectEvent) MarshalJSON ¶
func (d DirectEvent) MarshalJSON() ([]byte, error)
MarshalJSON marshals the internal list of rooms inside DirectEvent to be consistent with other events as they only include content in the marshalled JSON.
type Event ¶
type Event interface {
Info() *EventInfo
}
Event is a parsed instance of events in Matrix.
type EventInfo ¶
type EventInfo struct { // Raw is the raw event as the event was received. Raw RawEvent `json:"-"` Type Type `json:"type"` }
EventInfo contains information present in all events.
type FileInfo ¶
type FileInfo struct { MimeType string `json:"mimetype,omitempty"` // MIME type of image. Size int `json:"size,omitempty"` // Size in bytes. ThumbnailURL matrix.URL `json:"thumbnail_url,omitempty"` // Present if thumbnail is un-encrypted. ThumbnailFile encrypt.File `json:"thumbnail_file,omitempty"` // Present if thumbnail is encrypted. ThumbnailInfo ThumbnailInfo `json:"thumbnail_info,omitempty"` }
FileInfo stores the info of a file.
type Filter ¶
type Filter struct { // Maximum number of events to return. Limit int `json:"limit,omitempty"` // List of senders to include. All if not provided. IncludedSenders []matrix.UserID `json:"senders,omitempty"` // List of event types to include. All if not provided. // '*' can be used as a wildcard. IncludedTypes []Type `json:"types,omitempty"` // List of senders to exclude. Overrides IncludedSenders. ExcludedSenders []matrix.UserID `json:"not_senders,omitempty"` // List of event types to exclude. Overrides IncludedTypes. // '*' can be used as a wildcard. ExcludedTypes []Type `json:"not_types,omitempty"` }
Filter represents a filter that filters events that should be sent to the client.
type GlobalFilter ¶
type GlobalFilter struct { // List of event fields that should be included. EventFields []string `json:"event_fields,omitempty"` // The format to use. This implementation recommends the // use of "client" (default). // // Don't include if you don't know what you're doing. EventFormat string `json:"event_format,omitempty"` // List of presence updates to include. Presence Filter `json:"presence,omitempty"` // List of user account data updates to include. // This does not affect data associated with room. AccountData Filter `json:"account_data,omitempty"` // Filter to be applied to room data. Room RoomFilter `json:"room,omitempty"` }
GlobalFilter represents a filter that can be uploaded to/downloaded from the homeserver.
Servers MAY still send data that has been excluded by the filter. The filter only tells the server what is safe to not include.
type GuestAccess ¶
type GuestAccess string
GuestAccess is an enum that decides if a guest can join a room.
const ( GuestAccessCanJoin GuestAccess = "can_join" GuestAccessForbidden GuestAccess = "forbidden" )
The two possible values of GuestAccess.
type HistoryVisibility ¶
type HistoryVisibility string
HistoryVisibility specifies the group that can view the room history.
const ( // VisibilityInvited allows members to see history from the moment they were invited until // they are no longer invited or in the room. VisibilityInvited HistoryVisibility = "invited" // VisibilityJoined allows members to see history from the moment they join the room until // they are no longer in the room. VisibilityJoined HistoryVisibility = "joined" // as long as they are a member at some point. VisibilityShared HistoryVisibility = "shared" // VisibilityWorldReadable allows everyone to see all history including users who were never in the room. VisibilityWorldReadable HistoryVisibility = "world_readable" )
A list of possible visibility values. The default is "shared".
type ImageInfo ¶
type ImageInfo struct { FileInfo // Intended display size of image. Present if RoomMessageFileInfo is part of RoomMessageImage. Height int `json:"h,omitempty"` Width int `json:"w,omitempty"` }
ImageInfo stores the info of an image.
type JoinRule ¶
type JoinRule string
JoinRule represents the condition required to join a room.
const ( JoinPublic JoinRule = "public" JoinKnock JoinRule = "knock" JoinInvite JoinRule = "invite" JoinPrivate JoinRule = "private" )
"public" means the room can be joined by everyone while "invite" means the user must be invited before attempting to join.
"knock" and "private" are reserved keywords which are not implemented.
type LocationInfo ¶
type LocationInfo struct { ThumbnailURL matrix.URL `json:"thumbnail_url,omitempty"` // Present if thumbnail is un-encrypted. ThumbnailFile encrypt.File `json:"thumbnail_file,omitempty"` // Present if thumbnail is encrypted. ThumbnailInfo ThumbnailInfo `json:"thumbnail_info,omitempty"` }
LocationInfo stores the info of a location.
type MemberType ¶
type MemberType string
MemberType represents the type of member the user is in a room.
const ( MemberInvited MemberType = "invite" MemberJoined MemberType = "join" MemberLeft MemberType = "leave" MemberBanned MemberType = "ban" MemberKnock MemberType = "knock" )
Invited means that the user is invited and could join the room. Joined means that the user is already in the room. Left means that the user has not joined the room/left it. Banned means that the user has been banned.
Knock is reserved and not implemented.
type MessageFormat ¶
type MessageFormat string
MessageFormat is the type of the custom formatted body.
const (
FormatHTML MessageFormat = "org.matrix.custom.html"
)
Currently, HTML is the only known RoomMessageFormat.
type MessageType ¶
type MessageType string
MessageType is the type of message sent.
const ( // Text, Emote and Notice are all messages. // Text is a regular message, Emote is similar to /me in IRC and Notice is a message sent by a bot. RoomMessageText MessageType = "m.text" RoomMessageEmote MessageType = "m.emote" RoomMessageNotice MessageType = "m.notice" RoomMessageImage MessageType = "m.image" RoomMessageFile MessageType = "m.file" RoomMessageAudio MessageType = "m.audio" RoomMessageLocation MessageType = "m.location" RoomMessageVideo MessageType = "m.video" )
All possible RoomMessageEvent types. List available at https://spec.matrix.org/v1.1/client-server-api/#mroommessage-msgtypes.
type Partial ¶
type Partial struct { StateEventInfo Content json.RawMessage `json:"content"` }
Partial is a partially parsed event object. Its pointer implements StateEvent but is not guaranteed to be a state event or a room event. It aims to allow API users to inspect into events that fail to unmarshal because it is of an unknown event type.
func ParsePartial ¶
ParsePartial parses the raw event partially, leaving Content untouched and providing some fields common to most events exposed for inspection.
type PresenceEvent ¶
type PresenceEvent struct { EventInfo `json:"-"` User matrix.UserID `json:"-"` AvatarURL *matrix.URL `json:"avatar_url,omitempty"` DisplayName *string `json:"displayname,omitempty"` // Last time since user performed some action, in ms. LastActiveAgo *int `json:"last_active_ago,omitempty"` Presence matrix.Presence `json:"presence"` CurrentlyActive *bool `json:"currently_active,omitempty"` Status *string `json:"status_msg,omitempty"` // contains filtered or unexported fields }
PresenceEvent is an event where the presence of a user is updated.
func (PresenceEvent) LastActive ¶
func (p PresenceEvent) LastActive() *time.Time
LastActive calculates the last active time based on the time the event is parsed and the last active ago field. It is slightly off as the time the event is received is subject to network latency. It returns nil if the last active ago field is absent.
type PushRulesEvent ¶
type PushRulesEvent struct { EventInfo `json:"-"` // Global is the global ruleset. Global matrix.PushRuleset `json:"global"` }
PushRulesEvent is an event that describes all push rules for this user.
type RawEvent ¶
type RawEvent json.RawMessage
RawEvent is an instance of event that has not been parsed.
func (RawEvent) MarshalJSON ¶
MarshalJSON returns the raw event itself.
func (*RawEvent) UnmarshalJSON ¶
UnmarshalJSON sets *r to a copy of the data.
type ReceiptEvent ¶
type ReceiptEvent struct { EventInfo Events map[matrix.EventID]Receipt `json:"content"` RoomID matrix.RoomID `json:"room_id"` }
ReceiptEvent is an event where the read marker is updated.
type RoomAvatarEvent ¶
type RoomAvatarEvent struct { StateEventInfo `json:"-"` Image ImageInfo `json:"info,omitempty"` URL matrix.URL `json:"url"` }
RoomAvatarEvent represents a state event where the room avatar is set.
type RoomCanonicalAliasEvent ¶
type RoomCanonicalAliasEvent struct { StateEventInfo `json:"-"` // The canonical alias for the room. May be empty. Alias string `json:"alias,omitempty"` // Alternative aliases the room advertises. It can be present even if Alias is empty. AltAlias []string `json:"alt_aliases,omitempty"` }
RoomCanonicalAliasEvent represents a state event where the alias (name) of the room is set.
type RoomCreateEvent ¶
type RoomCreateEvent struct { StateEventInfo `json:"-"` // The user ID of the room creator. This is set by the homeserver. Creator matrix.UserID `json:"creator"` // Whether users from other servers can join. Defaults to true. Federated *bool `json:"m.federate,omitempty"` // Room Version. Defaults to "1" if not specified. RoomVersion *string `json:"room_version,omitempty"` }
RoomCreateEvent represents a state event where the room is created or upgraded. Do note that there's no order of Matrix version and it is still considered upgrading for "upgrading" version 2 to 1. It is the first event in any room.
type RoomEvent ¶
type RoomEvent interface { Info() *EventInfo RoomInfo() *RoomEventInfo }
RoomEvent is an event that is recorded in history and is not one-off. Typing is not a RoomEvent for example.
type RoomEventFilter ¶
type RoomEventFilter struct { // Limit is the maximum number of events to return. Limit int `json:"limit,omitempty"` // List of senders to include. All if omitted. IncludedSenders []matrix.UserID `json:"senders,omitempty"` // List of types to include. All if omitted. IncludedTypes []Type `json:"types,omitempty"` // List of rooms to include. All if omitted. IncludeRooms []matrix.RoomID `json:"rooms,omitempty"` // List of senders to exclude. Overrides IncludedSenders. ExcludedSenders []matrix.UserID `json:"not_senders,omitempty"` // List of types to exclude. Overrides IncludedTypes. ExcludedTypes []Type `json:"not_types,omitempty"` // List of rooms to exclude. Overrides IncludedRooms. ExcludedRooms []matrix.RoomID `json:"not_rooms,omitempty"` // Enable lazy loading members. If it's true, it'll only send // member info that are mentioned in events. // Other member data should be queried through the API if this // is true. LazyLoadMembers bool `json:"lazy_load_members,omitempty"` // The server does not send member info that it thinks the client // already knows by default. The server will include it instead if // this is set to true. IncludeRedundantMembers bool `json:"include_redundant_members,omitempty"` // Include only events with a `url` key in its content if `true`. // Include only events without a `url` key in its content if `false`. // `url` is not used to filter otherwise. ContainsURL *bool `json:"contains_url,omitempty"` }
RoomEventFilter represents a filter that filters room events.
type RoomEventInfo ¶
type RoomEventInfo struct { EventInfo ID matrix.EventID `json:"event_id,omitempty"` Sender matrix.UserID `json:"sender,omitempty"` OriginServerTime matrix.Timestamp `json:"origin_server_ts,omitempty"` RoomID matrix.RoomID `json:"room_id,omitempty"` // NOT included on `/sync` events. Unsigned UnsignedData `json:"unsigned,omitempty"` }
RoomEventInfo contains information present in all room events and state events.
func (*RoomEventInfo) RoomInfo ¶
func (r *RoomEventInfo) RoomInfo() *RoomEventInfo
RoomEventInfo returns itself so it can be embedded into a struct and allow the struct to implement RoomEvent.
type RoomFilter ¶
type RoomFilter struct { // Rooms to include. All if not provided. IncludedRooms []matrix.RoomID `json:"rooms,omitempty"` // Rooms to exclude. Overrides IncludedRoom. ExcludedRooms []matrix.RoomID `json:"not_rooms,omitempty"` // Ephemeral is the subfilter applied to events that are // not persistent (added to history) like typing. Ephemeral RoomEventFilter `json:"ephemeral,omitempty"` // The client will continue to listen to events from rooms // that the user has left if this is set to true. // Defaults to false. IncludeLeave bool `json:"include_leave,omitempty"` // State is the subfilter applied to state events. State StateFilter `json:"state,omitempty"` // Timeline is the subfilter applied to events that are // persistent (added to history) like messages. Timeline RoomEventFilter `json:"timeline,omitempty"` // AccountData is the subfilter applied to per user account // data. AccountData RoomEventFilter `json:"account_data,omitempty"` }
RoomFilter represents a filter that filters room data.
type RoomGuestAccessEvent ¶
type RoomGuestAccessEvent struct { StateEventInfo `json:"-"` GuestAccess GuestAccess `json:"guest_access"` }
RoomGuestAccessEvent is an event that controls whether guest users are allowed to join rooms. If the event is not present, it's inferred to be forbidden.
type RoomHistoryVisibilityEvent ¶
type RoomHistoryVisibilityEvent struct { StateEventInfo `json:"-"` Visibility HistoryVisibility `json:"history_visibility,omitempty"` }
RoomHistoryVisibilityEvent is an event where the visibility of history is changed.
type RoomJoinRulesEvent ¶
type RoomJoinRulesEvent struct { StateEventInfo `json:"-"` // The new rules to be applied to users wishing to join the room. JoinRule JoinRule `json:"join_rule"` }
RoomJoinRulesEvent represents a state event where the room's join rules are set.
type RoomMemberEvent ¶
type RoomMemberEvent struct { StateEventInfo `json:"-"` // The ID of the user for this event. UserID matrix.UserID `json:"-"` // The avatar URL of the user, if any. AvatarURL matrix.URL `json:"avatar_url,omitempty"` // The display name of the user, if any. DisplayName *string `json:"displayname,omitempty"` // The new state of the user in the room. NewState MemberType `json:"membership,omitempty"` // Flag indicating if the room was created with intention of being a DM. IsDirect bool `json:"is_direct,omitempty"` // Optional user-specified reason for the state change. // Clients are not recommended to show this reason to users when receiving // an invite due to the potential for spam and abuse. Hiding the reason // behind a button or other component is recommended. Reason string `json:"reason,omitempty"` // ThirdPartyInvites is set when it's an invite event and is the successor of a // m.room.third_party_invite event. ThirdPartyInvite struct { DisplayName string `json:"display_name"` } `json:"third_party_invite,omitempty"` // A purely INFORMATIONAL source that SHOULD NOT be trusted for the state of the room. // It may be present or absent. Unsigned struct { InviteRoomState []StrippedEvent `json:"invite_room_state"` } `json:"unsigned,omitempty"` }
RoomMemberEvent represents a state event where a user's membership state changes.
type RoomMessageEvent ¶
type RoomMessageEvent struct { RoomEventInfo `json:"-"` Body string `json:"body"` MessageType MessageType `json:"msgtype"` // This message is a reply to RelatesTo if present. RelatesTo json.RawMessage `json:"m.relates_to,omitempty"` // Optionally present in Text, Emote and Notice. Format MessageFormat `json:"format,omitempty"` FormattedBody string `json:"formatted_body,omitempty"` // This field is present in Location. GeoURI matrix.GeoURI `json:"geo_uri,omitempty"` // These fields are present in Image, File, Audio, Video. URL matrix.URL `json:"url,omitempty"` // Present if content is not encrypted. File *encrypt.File `json:"file,omitempty"` // Present if content is encrypted. // This field is present in Image, File, Audio, Video, Location. // The relevant parsing functions should be used. AdditionalInfo json.RawMessage `json:"info,omitempty"` // Also present in Location. }
RoomMessageEvent represents a room event where a message has been sent.
It has the type ID of `m.room.message`.
func (RoomMessageEvent) AudioInfo ¶
func (e RoomMessageEvent) AudioInfo() (AudioInfo, error)
AudioInfo parses info as an AudioInfo.
func (RoomMessageEvent) FileInfo ¶
func (e RoomMessageEvent) FileInfo() (FileInfo, error)
FileInfo parses info as a FileInfo.
func (RoomMessageEvent) ImageInfo ¶
func (e RoomMessageEvent) ImageInfo() (ImageInfo, error)
ImageInfo parses info as an ImageInfo.
func (*RoomMessageEvent) InReplyTo ¶
func (e *RoomMessageEvent) InReplyTo() matrix.EventID
InReplyTo parses the message's RelatesTo object and returns the event ID that the message replies to, if any. An empty event string is returned if the message does not reply to another event in a valid way.
func (RoomMessageEvent) LocationInfo ¶
func (e RoomMessageEvent) LocationInfo() (LocationInfo, error)
LocationInfo parses info as a LocationInfo.
func (RoomMessageEvent) StrippedBody ¶
func (e RoomMessageEvent) StrippedBody() string
StrippedBody should be used if the client is rich reply aware (uses the RelatesTo field) in place of Body.
func (RoomMessageEvent) VideoInfo ¶
func (e RoomMessageEvent) VideoInfo() (VideoInfo, error)
VideoInfo parses info as a VideoInfo.
type RoomNameEvent ¶
type RoomNameEvent struct { StateEventInfo `json:"-"` Name string `json:"name,omitempty"` // This must not exceed 255 bytes. }
RoomNameEvent represents a state event where the room name is set. This is only used to be displayed. It's not unique and names can be duplicated.
type RoomPinnedEvent ¶
type RoomPinnedEvent struct { StateEventInfo `json:"-"` Pinned []matrix.EventID `json:"pinned"` }
RoomPinnedEvent represents a state event where the list of events pinned are modified.
type RoomPowerLevelsEvent ¶
type RoomPowerLevelsEvent struct { StateEventInfo `json:"-"` // Ban, invite, kick and redact defaults to 50 if unspecified. BanRequirement *int `json:"ban,omitempty"` InviteRequirement *int `json:"invite,omitempty"` KickRequirement *int `json:"kick,omitempty"` RedactRequirement *int `json:"redact,omitempty"` // The power requirements of events. Events overrides the default. // The default for normal events is EventRequirement and // the default for state events is StateRequirement. Events map[Type]int `json:"events,omitempty"` EventRequirement int `json:"events_default,omitempty"` StateRequirement int `json:"state_default,omitempty"` // UserLevel is a map of user IDs to their power level. UserLevel map[matrix.UserID]int `json:"users,omitempty"` // The default power level of users (if not in UserLevel). UserDefault int `json:"users_default,omitempty"` Notifications struct { // The power level required to ping a room. Defaults to 50. Room *int `json:"room,omitempty"` } `json:"notifications,omitempty"` }
RoomPowerLevelsEvent represents a state event that establishes the power level and requirements for each event to be sent.
type RoomRedactionEvent ¶
type RoomRedactionEvent struct { RoomEventInfo `json:"-"` Redacts matrix.EventID `json:"-"` Reason string `json:"reason,omitempty"` }
RoomRedactionEvent is a message event where another event is redacted from the history. All keys associated with the event may be stripped off, causing the data to no longer be accessible. This can also be used for moderators to hide message events (which can be undone).
type RoomTombstoneEvent ¶
type RoomTombstoneEvent struct { StateEventInfo `json:"-"` Message string `json:"body,omitempty"` ReplacementRoom matrix.RoomID `json:"replacement_room,omitempty"` }
RoomTombstoneEvent is an event where the current room has been upgraded and a new room should be used instead.
type RoomTopicEvent ¶
type RoomTopicEvent struct { StateEventInfo `json:"-"` Topic string `json:"topic,omitempty"` }
RoomTopicEvent represents a state event where the room topic is set.
type StateEvent ¶
type StateEvent interface { Info() *EventInfo RoomInfo() *RoomEventInfo StateInfo() *StateEventInfo }
StateEvent is an event that records the change of a state.
type StateEventInfo ¶
type StateEventInfo struct { RoomEventInfo StateKey string `json:"state_key,omitempty"` PrevContent json.RawMessage `json:"prev_content,omitempty"` // Optional previous content, if available. }
StateEventInfo contains information present in all state events.
func (*StateEventInfo) StateInfo ¶
func (s *StateEventInfo) StateInfo() *StateEventInfo
StateEventInfo returns itself so it can be embedded into a struct and allow the struct to implement StateEvent.
type StateFilter ¶
type StateFilter struct { // Limit is the maximum number of events to return. Limit int `json:"limit,omitempty"` // List of senders to include. All if omitted. IncludedSenders []matrix.UserID `json:"senders,omitempty"` // List of types to include. All if omitted. IncludedTypes []Type `json:"types,omitempty"` // List of rooms to include. All if omitted. IncludeRooms []matrix.RoomID `json:"rooms,omitempty"` // List of senders to exclude. Overrides IncludedSenders. ExcludedSenders []matrix.UserID `json:"not_senders,omitempty"` // List of types to exclude. Overrides IncludedTypes. ExcludedTypes []Type `json:"not_types,omitempty"` // List of rooms to exclude. Overrides IncludedRooms. ExcludedRooms []matrix.RoomID `json:"not_rooms,omitempty"` // Enable lazy loading members. If it's true, it'll only send // member info that are mentioned in events. // Other member data should be queried through the API if this // is true. LazyLoadMembers bool `json:"lazy_load_members,omitempty"` // The server does not send member info that it thinks the client // already knows by default. The server will include it instead if // this is set to true. IncludeRedundantMembers bool `json:"include_redundant_members,omitempty"` // Include only events with a `url` key in its content if `true`. // Include only events without a `url` key in its content if `false`. // `url` is not used to filter otherwise. ContainsURL *bool `json:"contains_url,omitempty"` }
StateFilter represents a filter for state events.
type StrippedEvent ¶
type StrippedEvent RawEvent
StrippedEvent represents an event that has been stripped. This allows the client to display a room state correctly without its full timeline.
It has the Type, Content, StateKey and Sender field.
func (StrippedEvent) MarshalJSON ¶
func (r StrippedEvent) MarshalJSON() ([]byte, error)
MarshalJSON returns the stripped event itself.
func (*StrippedEvent) UnmarshalJSON ¶
func (r *StrippedEvent) UnmarshalJSON(msg []byte) error
UnmarshalJSON sets *r to a copy of the data.
type ThumbnailInfo ¶
type ThumbnailInfo struct { Height int `json:"h,omitempty"` // Intended height of thumbnail. Width int `json:"w,omitempty"` // Intended width of thumbnail. MimeType string `json:"mimetype,omitempty"` // MIME type of thumbnail. Size int `json:"size,omitempty"` // Size in bytes. }
ThumbnailInfo stores the info of a thumbnail.
type Type ¶
type Type string
Type is the type of the event that is contained in the contents field.
const ( TypeRoomCanonicalAlias Type = "m.room.canonical_alias" TypeRoomCreate Type = "m.room.create" TypeRoomJoinRules Type = "m.room.join_rules" TypeRoomMember Type = "m.room.member" TypeRoomPowerLevels Type = "m.room.power_levels" TypeRoomRedaction Type = "m.room.redaction" // Events from the Instant Messaging module. TypeRoomMessage Type = "m.room.message" TypeRoomName Type = "m.room.name" TypeRoomTopic Type = "m.room.topic" TypeRoomAvatar Type = "m.room.avatar" TypeRoomPinned Type = "m.room.pinned_events" // Events from the Direct Messaging module. TypeDirect Type = "m.direct" // Events from the Voice over IP module. TypeCallInvite Type = "m.call.invite" TypeCallCandidates Type = "m.call.candidates" TypeCallAnswer Type = "m.call.answer" TypeCallHangup Type = "m.call.hangup" // Events from the Typing Notifications module. TypeTyping Type = "m.typing" // Events from the Receipts module. TypeReceipt Type = "m.receipt" // Events from the Presence module. TypePresence Type = "m.presence" // Events from the History Visibility module. TypeRoomHistoryVisibility Type = "m.room.history_visibility" // Events from the Guest Access module. TypeRoomGuestAccess Type = "m.room.guest_access" // Events from the Tag module. TypeTag = "m.tag" // Events from the Room Upgrade module. TypeRoomTombstone Type = "m.room.tombstone" // Events from the Push Notifications module. TypePushRules Type = "m.push_rules" )
List of all known room events. NOTE: Update the 'parser' variable below as well.
type TypingEvent ¶
type TypingEvent struct { EventInfo `json:"-"` UserID []matrix.UserID `json:"user_ids"` RoomID matrix.RoomID `json:"-"` }
TypingEvent is an event that updates the list of users that are typing.
type UnknownEventTypeError ¶
type UnknownEventTypeError struct {
Found Type
}
UnknownEventTypeError represents an error where the event type is unknown and therefore cannot be mapped to its concrete type.
func (UnknownEventTypeError) Error ¶
func (e UnknownEventTypeError) Error() string
type UnsignedData ¶
type UnsignedData struct { // Age is the time in milliseconds that has elapsed since the event was sent. // It is generated by local homeserver and may be incorrect if either server's // time is out of sync. Age matrix.Duration `json:"age,omitempty"` // RedactReason is the event that redacted this event, if any. RedactReason RawEvent `json:"redacted_because,omitempty"` // TransactionID is the client-supplied transaction ID, if the client being given the event // is the same one which sent it. TransactionID string `json:"transaction_id,omitempty"` // PrevContent is the previous content for this event. If there is no previous content, this // key will be missing. PrevContent json.RawMessage `json:"prev_content,omitempty"` }
UnsignedData contains data controlled by the homeserver and is therefore not signed.