Version: v0.7.1 Latest Latest

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

Go to latest
Published: Aug 21, 2020 License: MPL-2.0 Imports: 12 Imported by: 120




View Source
const (
	KeyRequestActionRequest = "request"
	KeyRequestActionCancel  = "request_cancellation"
View Source
const (
	PresenceOnline      = "online"
	PresenceOffline     = "offline"
	PresenceUnavailable = "unavailable"
View Source
const ReplyFormat = `` /* 143-byte string literal not displayed */


View Source
var (
	StateAliases           = Type{"m.room.aliases", StateEventType}
	StateCanonicalAlias    = Type{"m.room.canonical_alias", StateEventType}
	StateCreate            = Type{"m.room.create", StateEventType}
	StateJoinRules         = Type{"m.room.join_rules", StateEventType}
	StateHistoryVisibility = Type{"m.room.history_visibility", StateEventType}
	StateGuestAccess       = Type{"m.room.guest_access", StateEventType}
	StateMember            = Type{"m.room.member", StateEventType}
	StatePowerLevels       = Type{"m.room.power_levels", StateEventType}
	StateRoomName          = Type{"m.room.name", StateEventType}
	StateTopic             = Type{"m.room.topic", StateEventType}
	StateRoomAvatar        = Type{"m.room.avatar", StateEventType}
	StatePinnedEvents      = Type{"m.room.pinned_events", StateEventType}
	StateTombstone         = Type{"m.room.tombstone", StateEventType}
	StateEncryption        = Type{"m.room.encryption", StateEventType}

State events

View Source
var (
	EventRedaction = Type{"m.room.redaction", MessageEventType}
	EventMessage   = Type{"m.room.message", MessageEventType}
	EventEncrypted = Type{"m.room.encrypted", MessageEventType}
	EventReaction  = Type{"m.reaction", MessageEventType}
	EventSticker   = Type{"m.sticker", MessageEventType}

Message events

View Source
var (
	EphemeralEventReceipt  = Type{"m.receipt", EphemeralEventType}
	EphemeralEventTyping   = Type{"m.typing", EphemeralEventType}
	EphemeralEventPresence = Type{"m.presence", EphemeralEventType}

Ephemeral events

View Source
var (
	AccountDataDirectChats     = Type{"m.direct", AccountDataEventType}
	AccountDataPushRules       = Type{"m.push_rules", AccountDataEventType}
	AccountDataRoomTags        = Type{"m.tag", AccountDataEventType}
	AccountDataFullyRead       = Type{"m.fully_read", AccountDataEventType}
	AccountDataIgnoredUserList = Type{"m.ignored_user_list", AccountDataEventType}

Account data events

View Source
var (
	ToDeviceRoomKey             = Type{"m.room_key", ToDeviceEventType}
	ToDeviceRoomKeyRequest      = Type{"m.room_key_request", ToDeviceEventType}
	ToDeviceForwardedRoomKey    = Type{"m.forwarded_room_key", ToDeviceEventType}
	ToDeviceEncrypted           = Type{"m.room.encrypted", ToDeviceEventType}
	ToDeviceRoomKeyWithheld     = Type{"m.room_key.withheld", ToDeviceEventType}
	ToDeviceVerificationRequest = Type{"m.key.verification.request", ToDeviceEventType}
	ToDeviceVerificationStart   = Type{"m.key.verification.start", ToDeviceEventType}
	ToDeviceVerificationAccept  = Type{"m.key.verification.accept", ToDeviceEventType}
	ToDeviceVerificationKey     = Type{"m.key.verification.key", ToDeviceEventType}
	ToDeviceVerificationMAC     = Type{"m.key.verification.mac", ToDeviceEventType}
	ToDeviceVerificationCancel  = Type{"m.key.verification.cancel", ToDeviceEventType}

	ToDeviceOrgMatrixRoomKeyWithheld = Type{"org.matrix.room_key.withheld", ToDeviceEventType}

Device-to-device events

View Source
var ContentAlreadyParsed = errors.New("content is already parsed")
View Source
var HTMLReplyFallbackRegex = regexp.MustCompile(`^<mx-reply>[\s\S]+?</mx-reply>`)
View Source
var TypeMap = map[Type]reflect.Type{
	StateMember:            reflect.TypeOf(MemberEventContent{}),
	StatePowerLevels:       reflect.TypeOf(PowerLevelsEventContent{}),
	StateCanonicalAlias:    reflect.TypeOf(CanonicalAliasEventContent{}),
	StateRoomName:          reflect.TypeOf(RoomNameEventContent{}),
	StateRoomAvatar:        reflect.TypeOf(RoomAvatarEventContent{}),
	StateTopic:             reflect.TypeOf(TopicEventContent{}),
	StateTombstone:         reflect.TypeOf(TombstoneEventContent{}),
	StateCreate:            reflect.TypeOf(CreateEventContent{}),
	StateJoinRules:         reflect.TypeOf(JoinRulesEventContent{}),
	StateHistoryVisibility: reflect.TypeOf(HistoryVisibilityEventContent{}),
	StateGuestAccess:       reflect.TypeOf(GuestAccessEventContent{}),
	StatePinnedEvents:      reflect.TypeOf(PinnedEventsEventContent{}),
	StateEncryption:        reflect.TypeOf(EncryptionEventContent{}),

	EventMessage:   reflect.TypeOf(MessageEventContent{}),
	EventSticker:   reflect.TypeOf(MessageEventContent{}),
	EventEncrypted: reflect.TypeOf(EncryptedEventContent{}),
	EventRedaction: reflect.TypeOf(RedactionEventContent{}),
	EventReaction:  reflect.TypeOf(ReactionEventContent{}),

	AccountDataRoomTags:        reflect.TypeOf(TagEventContent{}),
	AccountDataDirectChats:     reflect.TypeOf(DirectChatsEventContent{}),
	AccountDataFullyRead:       reflect.TypeOf(FullyReadEventContent{}),
	AccountDataIgnoredUserList: reflect.TypeOf(IgnoredUserListEventContent{}),

	EphemeralEventTyping:   reflect.TypeOf(TypingEventContent{}),
	EphemeralEventReceipt:  reflect.TypeOf(ReceiptEventContent{}),
	EphemeralEventPresence: reflect.TypeOf(PresenceEventContent{}),

	ToDeviceRoomKey:          reflect.TypeOf(RoomKeyEventContent{}),
	ToDeviceForwardedRoomKey: reflect.TypeOf(ForwardedRoomKeyEventContent{}),
	ToDeviceRoomKeyRequest:   reflect.TypeOf(RoomKeyRequestEventContent{}),
	ToDeviceEncrypted:        reflect.TypeOf(EncryptedEventContent{}),
	ToDeviceRoomKeyWithheld:  reflect.TypeOf(RoomKeyWithheldEventContent{}),

	ToDeviceVerificationStart:   reflect.TypeOf(VerificationStartEventContent{}),
	ToDeviceVerificationAccept:  reflect.TypeOf(VerificationAcceptEventContent{}),
	ToDeviceVerificationKey:     reflect.TypeOf(VerificationKeyEventContent{}),
	ToDeviceVerificationMAC:     reflect.TypeOf(VerificationMacEventContent{}),
	ToDeviceVerificationCancel:  reflect.TypeOf(VerificationCancelEventContent{}),
	ToDeviceVerificationRequest: reflect.TypeOf(VerificationRequestEventContent{}),

	ToDeviceOrgMatrixRoomKeyWithheld: reflect.TypeOf(RoomKeyWithheldEventContent{}),

TypeMap is a mapping from event type to the content struct type. This is used by Content.ParseRaw() for creating the correct type of struct.


func IsUnsupportedContentType

func IsUnsupportedContentType(err error) bool

func TrimReplyFallbackHTML

func TrimReplyFallbackHTML(html string) string

func TrimReplyFallbackText

func TrimReplyFallbackText(text string) string


type AnnotationChunk

type AnnotationChunk struct {
	Map map[string]int `json:"-"`

func (*AnnotationChunk) Serialize

func (ac *AnnotationChunk) Serialize() RelationChunk

func (*AnnotationChunk) UnmarshalJSON

func (ac *AnnotationChunk) UnmarshalJSON(data []byte) error

type CanonicalAliasEventContent

type CanonicalAliasEventContent struct {
	Alias      id.RoomAlias   `json:"alias"`
	AltAliases []id.RoomAlias `json:"alt_aliases,omitempty"`

CanonicalAliasEventContent represents the content of a m.room.canonical_alias state event. https://matrix.org/docs/spec/client_server/r0.6.1#m-room-canonical-alias

type Content

type Content struct {
	VeryRaw json.RawMessage
	Raw     map[string]interface{}
	Parsed  interface{}

Content stores the content of a Matrix event.

By default, the content is only parsed into a map[string]interface{}. However, you can call ParseRaw with the correct event type to parse the content into a nicer struct, which you can then access from Parsed or via the helper functions.

func (*Content) AsCanonicalAlias

func (content *Content) AsCanonicalAlias() *CanonicalAliasEventContent

func (*Content) AsCreate

func (content *Content) AsCreate() *CreateEventContent

func (*Content) AsDirectChats

func (content *Content) AsDirectChats() *DirectChatsEventContent

func (*Content) AsEncrypted

func (content *Content) AsEncrypted() *EncryptedEventContent

func (*Content) AsEncryption added in v0.3.7

func (content *Content) AsEncryption() *EncryptionEventContent

func (*Content) AsForwardedRoomKey

func (content *Content) AsForwardedRoomKey() *ForwardedRoomKeyEventContent

func (*Content) AsFullyRead

func (content *Content) AsFullyRead() *FullyReadEventContent

func (*Content) AsGuestAccess

func (content *Content) AsGuestAccess() *GuestAccessEventContent

func (*Content) AsHistoryVisibility

func (content *Content) AsHistoryVisibility() *HistoryVisibilityEventContent

func (*Content) AsIgnoredUserList

func (content *Content) AsIgnoredUserList() *IgnoredUserListEventContent

func (*Content) AsJoinRules

func (content *Content) AsJoinRules() *JoinRulesEventContent

func (*Content) AsMember

func (content *Content) AsMember() *MemberEventContent

func (*Content) AsMessage

func (content *Content) AsMessage() *MessageEventContent

func (*Content) AsPinnedEvents

func (content *Content) AsPinnedEvents() *PinnedEventsEventContent

func (*Content) AsPowerLevels

func (content *Content) AsPowerLevels() *PowerLevelsEventContent

func (*Content) AsPresence

func (content *Content) AsPresence() *PresenceEventContent

func (*Content) AsReaction

func (content *Content) AsReaction() *ReactionEventContent

func (*Content) AsReceipt

func (content *Content) AsReceipt() *ReceiptEventContent

func (*Content) AsRedaction

func (content *Content) AsRedaction() *RedactionEventContent

func (*Content) AsRoomAvatar

func (content *Content) AsRoomAvatar() *RoomAvatarEventContent

func (*Content) AsRoomKey

func (content *Content) AsRoomKey() *RoomKeyEventContent

func (*Content) AsRoomKeyRequest

func (content *Content) AsRoomKeyRequest() *RoomKeyRequestEventContent

func (*Content) AsRoomKeyWithheld added in v0.5.3

func (content *Content) AsRoomKeyWithheld() *RoomKeyWithheldEventContent

func (*Content) AsRoomName

func (content *Content) AsRoomName() *RoomNameEventContent

func (*Content) AsTag

func (content *Content) AsTag() *TagEventContent

func (*Content) AsTombstone

func (content *Content) AsTombstone() *TombstoneEventContent

func (*Content) AsTopic

func (content *Content) AsTopic() *TopicEventContent

func (*Content) AsTyping

func (content *Content) AsTyping() *TypingEventContent

func (*Content) MarshalJSON

func (content *Content) MarshalJSON() ([]byte, error)

func (*Content) ParseRaw

func (content *Content) ParseRaw(evtType Type) error

func (*Content) UnmarshalJSON

func (content *Content) UnmarshalJSON(data []byte) error

type CreateEventContent

type CreateEventContent struct {
	Creator     id.UserID `json:"creator"`
	Federate    bool      `json:"m.federate,omitempty"`
	RoomVersion string    `json:"version,omitempty"`
	Predecessor struct {
		RoomID  id.RoomID  `json:"room_id"`
		EventID id.EventID `json:"event_id"`
	} `json:"predecessor"`

CreateEventContent represents the content of a m.room.create state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-create

type DirectChatsEventContent

type DirectChatsEventContent map[id.UserID][]id.RoomID

DirectChatsEventContent represents the content of a m.direct account data event. https://matrix.org/docs/spec/client_server/r0.6.0#m-direct

type EncryptedEventContent

type EncryptedEventContent struct {
	Algorithm  id.Algorithm    `json:"algorithm"`
	SenderKey  id.SenderKey    `json:"sender_key"`
	DeviceID   id.DeviceID     `json:"device_id,omitempty"`
	SessionID  id.SessionID    `json:"session_id,omitempty"`
	Ciphertext json.RawMessage `json:"ciphertext"`

	MegolmCiphertext []byte         `json:"-"`
	OlmCiphertext    OlmCiphertexts `json:"-"`

	RelatesTo *RelatesTo `json:"m.relates_to,omitempty"`

EncryptedEventContent represents the content of a m.room.encrypted message event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-encrypted

func (*EncryptedEventContent) MarshalJSON

func (content *EncryptedEventContent) MarshalJSON() ([]byte, error)

func (*EncryptedEventContent) UnmarshalJSON

func (content *EncryptedEventContent) UnmarshalJSON(data []byte) error

type EncryptedFileInfo

type EncryptedFileInfo struct {
	URL id.ContentURIString `json:"url"`

type EncryptionEventContent

type EncryptionEventContent struct {
	// The encryption algorithm to be used to encrypt messages sent in this room. Must be 'm.megolm.v1.aes-sha2'.
	Algorithm id.Algorithm `json:"algorithm"`
	// How long the session should be used before changing it. 604800000 (a week) is the recommended default.
	RotationPeriodMillis int64 `json:"rotation_period_ms,omitempty"`
	// How many messages should be sent before changing the session. 100 is the recommended default.
	RotationPeriodMessages int `json:"rotation_period_msgs,omitempty"`

EncryptionEventContent represents the content of a m.room.encryption state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-encryption

type Event

type Event struct {
	StateKey  *string    `json:"state_key,omitempty"` // The state key for the event. Only present on State Events.
	Sender    id.UserID  `json:"sender"`              // The user ID of the sender of the event
	Type      Type       `json:"type"`                // The event type
	Timestamp int64      `json:"origin_server_ts"`    // The unix timestamp when this message was sent by the origin server
	ID        id.EventID `json:"event_id"`            // The unique ID of this event
	RoomID    id.RoomID  `json:"room_id"`             // The room the event was sent to. May be nil (e.g. for presence)
	Content   Content    `json:"content"`             // The JSON content of the event.
	Redacts   id.EventID `json:"redacts,omitempty"`   // The event ID that was redacted if a m.room.redaction event
	Unsigned  Unsigned   `json:"unsigned,omitempty"`  // Unsigned content set by own homeserver.

	Mautrix MautrixInfo `json:"-"`

Event represents a single Matrix event.

func (*Event) GenerateReplyFallbackHTML

func (evt *Event) GenerateReplyFallbackHTML() string

func (*Event) GenerateReplyFallbackText

func (evt *Event) GenerateReplyFallbackText() string

func (*Event) GetStateKey

func (evt *Event) GetStateKey() string

type EventIDChunk

type EventIDChunk struct {
	List []string `json:"-"`

func (*EventIDChunk) Serialize

func (ec *EventIDChunk) Serialize(typ RelationType) RelationChunk

func (*EventIDChunk) UnmarshalJSON

func (ec *EventIDChunk) UnmarshalJSON(data []byte) error

type FileInfo

type FileInfo struct {
	MimeType      string              `json:"mimetype,omitempty"`
	ThumbnailInfo *FileInfo           `json:"thumbnail_info,omitempty"`
	ThumbnailURL  id.ContentURIString `json:"thumbnail_url,omitempty"`
	ThumbnailFile *EncryptedFileInfo  `json:"thumbnail_file,omitempty"`
	Width         int                 `json:"-"`
	Height        int                 `json:"-"`
	Duration      int                 `json:"-"`
	Size          int                 `json:"-"`

func (*FileInfo) GetThumbnailInfo

func (fileInfo *FileInfo) GetThumbnailInfo() *FileInfo

func (*FileInfo) MarshalJSON

func (fileInfo *FileInfo) MarshalJSON() ([]byte, error)

func (*FileInfo) UnmarshalJSON

func (fileInfo *FileInfo) UnmarshalJSON(data []byte) error

type Format

type Format string

Format specifies the format of the formatted_body in m.room.message events. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-message-msgtypes

const (
	FormatHTML Format = "org.matrix.custom.html"

Message formats

type ForwardedRoomKeyEventContent

type ForwardedRoomKeyEventContent struct {
	SenderKey          id.SenderKey `json:"sender_key"`
	SenderClaimedKey   id.Ed25519   `json:"sender_claimed_ed25519_key"`
	ForwardingKeyChain []string     `json:"forwarding_curve25519_key_chain"`

ForwardedRoomKeyEventContent represents the content of a m.forwarded_room_key to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-forwarded-room-key

type FullyReadEventContent

type FullyReadEventContent struct {
	EventID id.EventID `json:"event_id"`

FullyReadEventContent represents the content of a m.fully_read account data event. https://matrix.org/docs/spec/client_server/r0.6.0#m-fully-read

type GuestAccess

type GuestAccess string

GuestAccess specifies whether or not guest accounts can join. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-guest-access

const (
	GuestAccessCanJoin   GuestAccess = "can_join"
	GuestAccessForbidden GuestAccess = "forbidden"

type GuestAccessEventContent

type GuestAccessEventContent struct {
	GuestAccess GuestAccess `json:"guest_access"`

GuestAccessEventContent represents the content of a m.room.guest_access state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-guest-access

type HistoryVisibility

type HistoryVisibility string

HistoryVisibility specifies who can see new messages. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-history-visibility

const (
	HistoryVisibilityInvited       HistoryVisibility = "invited"
	HistoryVisibilityJoined        HistoryVisibility = "joined"
	HistoryVisibilityShared        HistoryVisibility = "shared"
	HistoryVisibilityWorldReadable HistoryVisibility = "world_readable"

type HistoryVisibilityEventContent

type HistoryVisibilityEventContent struct {
	HistoryVisibility HistoryVisibility `json:"history_visibility"`

HistoryVisibilityEventContent represents the content of a m.room.history_visibility state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-history-visibility

type IgnoredUser

type IgnoredUser struct {

type IgnoredUserListEventContent

type IgnoredUserListEventContent struct {
	IgnoredUsers map[id.UserID]IgnoredUser `json:"ignored_users"`

IgnoredUserListEventContent represents the content of a m.ignored_user_list account data event. https://matrix.org/docs/spec/client_server/r0.6.0#m-ignored-user-list

type JoinRule

type JoinRule string

JoinRule specifies how open a room is to new members. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-join-rules

const (
	JoinRulePublic  JoinRule = "public"
	JoinRuleKnock   JoinRule = "knock"
	JoinRuleInvite  JoinRule = "invite"
	JoinRulePrivate JoinRule = "private"

type JoinRulesEventContent

type JoinRulesEventContent struct {
	JoinRule JoinRule `json:"join_rule"`

JoinRulesEventContent represents the content of a m.room.join_rules state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-join-rules

type KeyAgreementProtocol added in v0.7.0

type KeyAgreementProtocol string
const (
	KeyAgreementCurve25519           KeyAgreementProtocol = "curve25519"
	KeyAgreementCurve25519HKDFSHA256 KeyAgreementProtocol = "curve25519-hkdf-sha256"

type KeyRequestAction

type KeyRequestAction string

type MACMethod added in v0.7.0

type MACMethod string
const HKDFHMACSHA256 MACMethod = "hkdf-hmac-sha256"

type MautrixInfo added in v0.4.7

type MautrixInfo struct {
	Verified bool

type MemberEventContent

type MemberEventContent struct {
	Membership       Membership          `json:"membership"`
	AvatarURL        id.ContentURIString `json:"avatar_url,omitempty"`
	Displayname      string              `json:"displayname,omitempty"`
	IsDirect         bool                `json:"is_direct,omitempty"`
	ThirdPartyInvite *ThirdPartyInvite   `json:"third_party_invite,omitempty"`
	Reason           string              `json:"reason,omitempty"`

MemberEventContent represents the content of a m.room.member state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-member

type Membership

type Membership string

Membership is an enum specifying the membership state of a room member.

const (
	MembershipJoin   Membership = "join"
	MembershipLeave  Membership = "leave"
	MembershipInvite Membership = "invite"
	MembershipBan    Membership = "ban"
	MembershipKnock  Membership = "knock"

The allowed membership states as specified in spec section 10.5.5.

func (Membership) IsInviteOrJoin

func (ms Membership) IsInviteOrJoin() bool

func (Membership) IsLeaveOrBan

func (ms Membership) IsLeaveOrBan() bool

type MessageEventContent

type MessageEventContent struct {
	// Base m.room.message fields
	MsgType MessageType `json:"msgtype"`
	Body    string      `json:"body"`

	// Extra fields for text types
	Format        Format `json:"format,omitempty"`
	FormattedBody string `json:"formatted_body,omitempty"`

	// Extra field for m.location
	GeoURI string `json:"geo_uri,omitempty"`

	// Extra fields for media types
	URL  id.ContentURIString `json:"url,omitempty"`
	Info *FileInfo           `json:"info,omitempty"`
	File *EncryptedFileInfo  `json:"file,omitempty"`

	// Edits and relations
	NewContent *MessageEventContent `json:"m.new_content,omitempty"`
	RelatesTo  *RelatesTo           `json:"m.relates_to,omitempty"`
	// contains filtered or unexported fields

MssageEventContent represents the content of a m.room.message event.

It is also used to represent m.sticker events, as they are equivalent to m.room.message with the exception of the msgtype field.


func (*MessageEventContent) GetFile

func (content *MessageEventContent) GetFile() *EncryptedFileInfo

func (*MessageEventContent) GetInfo

func (content *MessageEventContent) GetInfo() *FileInfo

func (*MessageEventContent) GetRelatesTo

func (content *MessageEventContent) GetRelatesTo() *RelatesTo

func (*MessageEventContent) GetReplyTo

func (content *MessageEventContent) GetReplyTo() id.EventID

func (*MessageEventContent) OptionalGetRelatesTo

func (content *MessageEventContent) OptionalGetRelatesTo() *RelatesTo

func (*MessageEventContent) RemoveReplyFallback

func (content *MessageEventContent) RemoveReplyFallback()

func (*MessageEventContent) SetRelatesTo

func (content *MessageEventContent) SetRelatesTo(rel *RelatesTo)

func (*MessageEventContent) SetReply

func (content *MessageEventContent) SetReply(inReplyTo *Event)

type MessageType

type MessageType string

MessageType is the sub-type of a m.room.message event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-message-msgtypes

const (
	MsgText     MessageType = "m.text"
	MsgEmote    MessageType = "m.emote"
	MsgNotice   MessageType = "m.notice"
	MsgImage    MessageType = "m.image"
	MsgLocation MessageType = "m.location"
	MsgVideo    MessageType = "m.video"
	MsgAudio    MessageType = "m.audio"
	MsgFile     MessageType = "m.file"


type OlmCiphertexts

type OlmCiphertexts map[id.Curve25519]struct {
	Body string        `json:"body"`
	Type id.OlmMsgType `json:"type"`

type PinnedEventsEventContent

type PinnedEventsEventContent struct {
	Pinned []id.EventID `json:"pinned"`

PinnedEventsEventContent represents the content of a m.room.pinned_events state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-pinned-events

type PowerLevelsEventContent

type PowerLevelsEventContent struct {
	Users        map[id.UserID]int `json:"users"`
	UsersDefault int               `json:"users_default"`

	Events        map[string]int `json:"events"`
	EventsDefault int            `json:"events_default"`

	StateDefaultPtr *int `json:"state_default,omitempty"`

	InvitePtr *int `json:"invite,omitempty"`
	KickPtr   *int `json:"kick,omitempty"`
	BanPtr    *int `json:"ban,omitempty"`
	RedactPtr *int `json:"redact,omitempty"`
	// contains filtered or unexported fields

PowerLevelsEventContent represents the content of a m.room.power_levels state event content. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-power-levels

func (*PowerLevelsEventContent) Ban

func (pl *PowerLevelsEventContent) Ban() int

func (*PowerLevelsEventContent) EnsureEventLevel

func (pl *PowerLevelsEventContent) EnsureEventLevel(eventType Type, level int) bool

func (*PowerLevelsEventContent) EnsureUserLevel

func (pl *PowerLevelsEventContent) EnsureUserLevel(userID id.UserID, level int) bool

func (*PowerLevelsEventContent) GetEventLevel

func (pl *PowerLevelsEventContent) GetEventLevel(eventType Type) int

func (*PowerLevelsEventContent) GetUserLevel

func (pl *PowerLevelsEventContent) GetUserLevel(userID id.UserID) int

func (*PowerLevelsEventContent) Invite

func (pl *PowerLevelsEventContent) Invite() int

func (*PowerLevelsEventContent) Kick

func (pl *PowerLevelsEventContent) Kick() int

func (*PowerLevelsEventContent) Redact

func (pl *PowerLevelsEventContent) Redact() int

func (*PowerLevelsEventContent) SetEventLevel

func (pl *PowerLevelsEventContent) SetEventLevel(eventType Type, level int)

func (*PowerLevelsEventContent) SetUserLevel

func (pl *PowerLevelsEventContent) SetUserLevel(userID id.UserID, level int)

func (*PowerLevelsEventContent) StateDefault

func (pl *PowerLevelsEventContent) StateDefault() int

type Presence

type Presence string

type PresenceEventContent

type PresenceEventContent struct {
	Presence        Presence            `json:"presence"`
	Displayname     string              `json:"displayname,omitempty"`
	AvatarURL       id.ContentURIString `json:"avatar_url,omitempty"`
	LastActiveAgo   int64               `json:"last_active_ago,omitempty"`
	CurrentlyActive bool                `json:"currently_active,omitempty"`
	StatusMessage   string              `json:"status_msg,omitempty"`

PresenceEventContent represents the content of a m.presence ephemeral event. https://matrix.org/docs/spec/client_server/r0.6.0#m-presence

type ReactionEventContent

type ReactionEventContent struct {
	RelatesTo RelatesTo `json:"m.relates_to"`

ReactionEventContent represents the content of a m.reaction message event. This is not yet in a spec release, see https://github.com/matrix-org/matrix-doc/pull/1849

func (*ReactionEventContent) GetRelatesTo

func (content *ReactionEventContent) GetRelatesTo() *RelatesTo

func (*ReactionEventContent) OptionalGetRelatesTo

func (content *ReactionEventContent) OptionalGetRelatesTo() *RelatesTo

func (*ReactionEventContent) SetRelatesTo

func (content *ReactionEventContent) SetRelatesTo(rel *RelatesTo)

type ReadReceipt

type ReadReceipt struct {
	Timestamp int64 `json:"ts"`

func (*ReadReceipt) UnmarshalJSON

func (rr *ReadReceipt) UnmarshalJSON(data []byte) error

type ReceiptEventContent

type ReceiptEventContent map[id.EventID]Receipts

ReceiptEventContent represents the content of a m.receipt ephemeral event. https://matrix.org/docs/spec/client_server/r0.6.0#m-receipt

type Receipts

type Receipts struct {
	Read map[id.UserID]ReadReceipt `json:"m.read"`

type RedactionEventContent

type RedactionEventContent struct {
	Reason string `json:"reason,omitempty"`

RedactionEventContent represents the content of a m.room.redaction message event.

The redacted event ID is still at the top level, but will move in a future room version. See https://github.com/matrix-org/matrix-doc/pull/2244 and https://github.com/matrix-org/matrix-doc/pull/2174


type Relatable

type Relatable interface {
	GetRelatesTo() *RelatesTo
	OptionalGetRelatesTo() *RelatesTo
	SetRelatesTo(rel *RelatesTo)

type RelatesTo

type RelatesTo struct {
	Type    RelationType
	EventID id.EventID
	Key     string

func (*RelatesTo) GetAnnotationID

func (rel *RelatesTo) GetAnnotationID() id.EventID

func (*RelatesTo) GetAnnotationKey

func (rel *RelatesTo) GetAnnotationKey() string

func (*RelatesTo) GetReferenceID

func (rel *RelatesTo) GetReferenceID() id.EventID

func (*RelatesTo) GetReplaceID

func (rel *RelatesTo) GetReplaceID() id.EventID

func (*RelatesTo) MarshalJSON

func (rel *RelatesTo) MarshalJSON() ([]byte, error)

func (*RelatesTo) UnmarshalJSON

func (rel *RelatesTo) UnmarshalJSON(data []byte) error

type RelationChunk

type RelationChunk struct {
	Chunk []RelationChunkItem `json:"chunk"`

	Limited bool `json:"limited"`
	Count   int  `json:"count"`

type RelationChunkItem

type RelationChunkItem struct {
	Type    RelationType `json:"type"`
	EventID string       `json:"event_id,omitempty"`
	Key     string       `json:"key,omitempty"`
	Count   int          `json:"count,omitempty"`

type RelationType

type RelationType string
const (
	RelReplace    RelationType = "m.replace"
	RelReference  RelationType = "m.reference"
	RelAnnotation RelationType = "m.annotation"

type Relations

type Relations struct {
	Raw map[RelationType]RelationChunk `json:"-"`

	Annotations AnnotationChunk `json:"m.annotation,omitempty"`
	References  EventIDChunk    `json:"m.reference,omitempty"`
	Replaces    EventIDChunk    `json:"m.replace,omitempty"`

func (*Relations) MarshalJSON

func (relations *Relations) MarshalJSON() ([]byte, error)

func (*Relations) UnmarshalJSON

func (relations *Relations) UnmarshalJSON(data []byte) error

type RequestedKeyInfo

type RequestedKeyInfo struct {
	Algorithm id.Algorithm `json:"algorithm"`
	RoomID    id.RoomID    `json:"room_id"`
	SenderKey id.SenderKey `json:"sender_key"`
	SessionID id.SessionID `json:"session_id"`

type RoomAvatarEventContent

type RoomAvatarEventContent struct {
	URL id.ContentURI `json:"url"`

RoomAvatarEventContent represents the content of a m.room.avatar state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-avatar

type RoomKeyEventContent

type RoomKeyEventContent struct {
	Algorithm  id.Algorithm `json:"algorithm"`
	RoomID     id.RoomID    `json:"room_id"`
	SessionID  id.SessionID `json:"session_id"`
	SessionKey string       `json:"session_key"`

RoomKeyEventContent represents the content of a m.room_key to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-key

type RoomKeyRequestEventContent

type RoomKeyRequestEventContent struct {
	Body               RequestedKeyInfo `json:"body"`
	Action             KeyRequestAction `json:"action"`
	RequestingDeviceID id.DeviceID      `json:"requesting_device_id"`
	RequestID          string           `json:"request_id"`

RoomKeyRequestEventContent represents the content of a m.room_key_request to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-key-request

type RoomKeyWithheldCode added in v0.5.3

type RoomKeyWithheldCode string
const (
	RoomKeyWithheldBlacklisted  RoomKeyWithheldCode = "m.blacklisted"
	RoomKeyWithheldUnverified   RoomKeyWithheldCode = "m.unverified"
	RoomKeyWithheldUnauthorized RoomKeyWithheldCode = "m.unauthorized"
	RoomKeyWithheldUnavailable  RoomKeyWithheldCode = "m.unavailable"
	RoomKeyWithheldNoOlmSession RoomKeyWithheldCode = "m.no_olm"

type RoomKeyWithheldEventContent added in v0.5.3

type RoomKeyWithheldEventContent struct {
	RoomID    id.RoomID           `json:"room_id,omitempty"`
	Algorithm id.Algorithm        `json:"algorithm"`
	SessionID id.SessionID        `json:"session_id,omitempty"`
	SenderKey id.SenderKey        `json:"sender_key"`
	Code      RoomKeyWithheldCode `json:"code"`
	Reason    string              `json:"reason,omitempty"`

type RoomNameEventContent

type RoomNameEventContent struct {
	Name string `json:"name"`

RoomNameEventContent represents the content of a m.room.name state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-name

type SASMethod added in v0.7.0

type SASMethod string
const (
	SASDecimal SASMethod = "decimal"
	SASEmoji   SASMethod = "emoji"

type StrippedState

type StrippedState struct {
	Content  Content `json:"content"`
	Type     Type    `json:"type"`
	StateKey string  `json:"state_key"`

type Tag

type Tag struct {
	Order json.Number `json:"order"`

type TagEventContent

type TagEventContent struct {
	Tags Tags `json:"tags"`

TagEventContent represents the content of a m.tag room account data event. https://matrix.org/docs/spec/client_server/r0.6.0#m-tag

type Tags

type Tags map[string]Tag

type ThirdPartyInvite

type ThirdPartyInvite struct {
	DisplayName string `json:"display_name"`
	Signed      struct {
		Token      string          `json:"token"`
		Signatures json.RawMessage `json:"signatures"`
		MXID       string          `json:"mxid"`

type TombstoneEventContent

type TombstoneEventContent struct {
	Body            string    `json:"body"`
	ReplacementRoom id.RoomID `json:"replacement_room"`

TombstoneEventContent represents the content of a m.room.tombstone state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-tombstone

type TopicEventContent

type TopicEventContent struct {
	Topic string `json:"topic"`

TopicEventContent represents the content of a m.room.topic state event. https://matrix.org/docs/spec/client_server/r0.6.0#m-room-topic

type Type

type Type struct {
	Type  string
	Class TypeClass

func NewEventType

func NewEventType(name string) Type

func (*Type) GuessClass

func (et *Type) GuessClass() TypeClass

func (*Type) IsAccountData

func (et *Type) IsAccountData() bool

func (*Type) IsCustom

func (et *Type) IsCustom() bool

func (*Type) IsEphemeral

func (et *Type) IsEphemeral() bool

func (*Type) IsState

func (et *Type) IsState() bool

func (*Type) IsToDevice

func (et *Type) IsToDevice() bool

func (*Type) MarshalJSON

func (et *Type) MarshalJSON() ([]byte, error)

func (Type) MarshalText added in v0.3.2

func (et Type) MarshalText() ([]byte, error)

func (*Type) Repr

func (et *Type) Repr() string

func (*Type) String

func (et *Type) String() string

func (*Type) UnmarshalJSON

func (et *Type) UnmarshalJSON(data []byte) error

func (Type) UnmarshalText added in v0.3.2

func (et Type) UnmarshalText(data []byte) error

type TypeClass

type TypeClass int
const (
	// Normal message events
	MessageEventType TypeClass = iota
	// State events
	// Ephemeral events
	// Account data events
	// Device-to-device events
	// Unknown events

func (TypeClass) Name

func (tc TypeClass) Name() string

type TypingEventContent

type TypingEventContent struct {
	UserIDs []id.UserID `json:"user_ids"`

TagEventContent represents the content of a m.typing ephemeral event. https://matrix.org/docs/spec/client_server/r0.6.0#m-typing

type Unsigned

type Unsigned struct {
	PrevContent     *Content        `json:"prev_content,omitempty"`
	PrevSender      id.UserID       `json:"prev_sender,omitempty"`
	ReplacesState   id.EventID      `json:"replaces_state,omitempty"`
	Age             int64           `json:"age,omitempty"`
	TransactionID   string          `json:"transaction_id,omitempty"`
	Relations       Relations       `json:"m.relations,omitempty"`
	RedactedBecause *Event          `json:"redacted_because,omitempty"`
	InviteRoomState []StrippedState `json:"invite_room_state"`

type VerificationAcceptEventContent added in v0.7.0

type VerificationAcceptEventContent struct {
	// An opaque identifier for the verification process. Must be the same as the one used for the m.key.verification.start message.
	TransactionID string `json:"transaction_id"`
	// The verification method to use.
	Method VerificationMethod `json:"method"`
	// The key agreement protocol the device is choosing to use, out of the options in the m.key.verification.start message.
	KeyAgreementProtocol KeyAgreementProtocol `json:"key_agreement_protocol"`
	// The hash method the device is choosing to use, out of the options in the m.key.verification.start message.
	Hash VerificationHashMethod `json:"hash"`
	// The message authentication code the device is choosing to use, out of the options in the m.key.verification.start message.
	MessageAuthenticationCode MACMethod `json:"message_authentication_code"`
	// The SAS methods both devices involved in the verification process understand. Must be a subset of the options in the m.key.verification.start message.
	ShortAuthenticationString []SASMethod `json:"short_authentication_string"`
	// The hash (encoded as unpadded base64) of the concatenation of the device's ephemeral public key (encoded as unpadded base64) and the canonical JSON representation of the m.key.verification.start message.
	Commitment string `json:"commitment"`

VerificationAcceptEventContent represents the content of a m.key.verification.accept to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-key-verification-accept

type VerificationCancelCode added in v0.7.0

type VerificationCancelCode string
const (
	VerificationCancelByUser             VerificationCancelCode = "m.user"
	VerificationCancelByTimeout          VerificationCancelCode = "m.timeout"
	VerificationCancelUnknownTransaction VerificationCancelCode = "m.unknown_transaction"
	VerificationCancelUnknownMethod      VerificationCancelCode = "m.unknown_method"
	VerificationCancelUnexpectedMessage  VerificationCancelCode = "m.unexpected_message"
	VerificationCancelKeyMismatch        VerificationCancelCode = "m.key_mismatch"
	VerificationCancelUserMismatch       VerificationCancelCode = "m.user_mismatch"
	VerificationCancelInvalidMessage     VerificationCancelCode = "m.invalid_message"
	VerificationCancelAccepted           VerificationCancelCode = "m.accepted"
	VerificationCancelSASMismatch        VerificationCancelCode = "m.mismatched_sas"
	VerificationCancelCommitmentMismatch VerificationCancelCode = "m.mismatched_commitment"

type VerificationCancelEventContent added in v0.7.0

type VerificationCancelEventContent struct {
	// The opaque identifier for the verification process/request.
	TransactionID string `json:"transaction_id"`
	// A human readable description of the code. The client should only rely on this string if it does not understand the code.
	Reason string `json:"reason"`
	// The error code for why the process/request was cancelled by the user.
	Code VerificationCancelCode `json:"code"`

VerificationCancelEventContent represents the content of a m.key.verification.cancel to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-key-verification-cancel

type VerificationHashMethod added in v0.7.0

type VerificationHashMethod string
const VerificationHashSHA256 VerificationHashMethod = "sha256"

type VerificationKeyEventContent added in v0.7.0

type VerificationKeyEventContent struct {
	// An opaque identifier for the verification process. Must be the same as the one used for the m.key.verification.start message.
	TransactionID string `json:"transaction_id"`
	// The device's ephemeral public key, encoded as unpadded base64.
	Key string `json:"key"`

VerificationKeyEventContent represents the content of a m.key.verification.key to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-key-verification-key

type VerificationMacEventContent added in v0.7.0

type VerificationMacEventContent struct {
	// An opaque identifier for the verification process. Must be the same as the one used for the m.key.verification.start message.
	TransactionID string `json:"transaction_id"`
	// A map of the key ID to the MAC of the key, using the algorithm in the verification process. The MAC is encoded as unpadded base64.
	Mac map[id.KeyID]string `json:"mac"`
	// The MAC of the comma-separated, sorted, list of key IDs given in the mac property, encoded as unpadded base64.
	Keys string `json:"keys"`

VerificationMacEventContent represents the content of a m.key.verification.mac to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-key-verification-mac

type VerificationMethod added in v0.7.0

type VerificationMethod string
const VerificationMethodSAS VerificationMethod = "m.sas.v1"

type VerificationRequestEventContent added in v0.7.0

type VerificationRequestEventContent struct {
	// The device ID which is initiating the request.
	FromDevice id.DeviceID `json:"from_device"`
	// An opaque identifier for the verification request. Must be unique with respect to the devices involved.
	TransactionID string `json:"transaction_id"`
	// The verification methods supported by the sender.
	Methods []VerificationMethod `json:"methods"`
	// The POSIX timestamp in milliseconds for when the request was made.
	Timestamp int64 `json:"timestamp"`

VerificationRequestEventContent represents the content of a m.key.verification.request to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-key-verification-request

func (*VerificationRequestEventContent) SupportsVerificationMethod added in v0.7.0

func (vrec *VerificationRequestEventContent) SupportsVerificationMethod(meth VerificationMethod) bool

type VerificationStartEventContent added in v0.7.0

type VerificationStartEventContent struct {
	// The device ID which is initiating the process.
	FromDevice id.DeviceID `json:"from_device"`
	// An opaque identifier for the verification process. Must be unique with respect to the devices involved.
	TransactionID string `json:"transaction_id"`
	// The verification method to use.
	Method VerificationMethod `json:"method"`
	// The key agreement protocols the sending device understands.
	KeyAgreementProtocols []KeyAgreementProtocol `json:"key_agreement_protocols"`
	// The hash methods the sending device understands.
	Hashes []VerificationHashMethod `json:"hashes"`
	// The message authentication codes that the sending device understands.
	MessageAuthenticationCodes []MACMethod `json:"message_authentication_codes"`
	// The SAS methods the sending device (and the sending device's user) understands.
	ShortAuthenticationString []SASMethod `json:"short_authentication_string"`

VerificationStartEventContent represents the content of a m.key.verification.start to_device event. https://matrix.org/docs/spec/client_server/r0.6.0#m-key-verification-start

func (*VerificationStartEventContent) SupportsHashMethod added in v0.7.0

func (vsec *VerificationStartEventContent) SupportsHashMethod(alg VerificationHashMethod) bool

func (*VerificationStartEventContent) SupportsKeyAgreementProtocol added in v0.7.0

func (vsec *VerificationStartEventContent) SupportsKeyAgreementProtocol(proto KeyAgreementProtocol) bool

func (*VerificationStartEventContent) SupportsMACMethod added in v0.7.0

func (vsec *VerificationStartEventContent) SupportsMACMethod(meth MACMethod) bool

func (*VerificationStartEventContent) SupportsSASMethod added in v0.7.0

func (vsec *VerificationStartEventContent) SupportsSASMethod(meth SASMethod) bool

Jump to

Keyboard shortcuts

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