event

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MPL-2.0 Imports: 20 Imported by: 202

Documentation

Index

Constants

View Source
const (
	KeyRequestActionRequest = "request"
	KeyRequestActionCancel  = "request_cancellation"
)
View Source
const (
	SecretRequestRequest      = "request"
	SecretRequestCancellation = "request_cancellation"
)

Variables

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}
	StateServerACL         = Type{"m.room.server_acl", StateEventType}
	StateTombstone         = Type{"m.room.tombstone", StateEventType}
	StatePolicyRoom        = Type{"m.policy.rule.room", StateEventType}
	StatePolicyServer      = Type{"m.policy.rule.server", StateEventType}
	StatePolicyUser        = Type{"m.policy.rule.user", StateEventType}
	StateEncryption        = Type{"m.room.encryption", StateEventType}
	StateBridge            = Type{"m.bridge", StateEventType}
	StateHalfShotBridge    = Type{"uk.half-shot.bridge", StateEventType}
	StateSpaceChild        = Type{"m.space.child", StateEventType}
	StateSpaceParent       = Type{"m.space.parent", StateEventType}

	StateLegacyPolicyRoom     = Type{"m.room.rule.room", StateEventType}
	StateLegacyPolicyServer   = Type{"m.room.rule.server", StateEventType}
	StateLegacyPolicyUser     = Type{"m.room.rule.user", StateEventType}
	StateUnstablePolicyRoom   = Type{"org.matrix.mjolnir.rule.room", StateEventType}
	StateUnstablePolicyServer = Type{"org.matrix.mjolnir.rule.server", StateEventType}
	StateUnstablePolicyUser   = Type{"org.matrix.mjolnir.rule.user", StateEventType}

	// Deprecated: MSC2716 has been abandoned
	StateInsertionMarker = Type{"org.matrix.msc2716.marker", StateEventType}

	StateElementFunctionalMembers = Type{"io.element.functional_members", 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}

	InRoomVerificationReady  = Type{"m.key.verification.ready", MessageEventType}
	InRoomVerificationStart  = Type{"m.key.verification.start", MessageEventType}
	InRoomVerificationDone   = Type{"m.key.verification.done", MessageEventType}
	InRoomVerificationCancel = Type{"m.key.verification.cancel", MessageEventType}

	// SAS Verification Events
	InRoomVerificationAccept = Type{"m.key.verification.accept", MessageEventType}
	InRoomVerificationKey    = Type{"m.key.verification.key", MessageEventType}
	InRoomVerificationMAC    = Type{"m.key.verification.mac", MessageEventType}

	CallInvite       = Type{"m.call.invite", MessageEventType}
	CallCandidates   = Type{"m.call.candidates", MessageEventType}
	CallAnswer       = Type{"m.call.answer", MessageEventType}
	CallReject       = Type{"m.call.reject", MessageEventType}
	CallSelectAnswer = Type{"m.call.select_answer", MessageEventType}
	CallNegotiate    = Type{"m.call.negotiate", MessageEventType}
	CallHangup       = Type{"m.call.hangup", MessageEventType}

	BeeperMessageStatus = Type{"com.beeper.message_send_status", MessageEventType}

	EventUnstablePollStart    = Type{Type: "org.matrix.msc3381.poll.start", Class: MessageEventType}
	EventUnstablePollResponse = Type{Type: "org.matrix.msc3381.poll.response", Class: 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}
	AccountDataMarkedUnread    = Type{"m.marked_unread", AccountDataEventType}
	AccountDataBeeperMute      = Type{"com.beeper.mute", AccountDataEventType}

	AccountDataSecretStorageDefaultKey = Type{"m.secret_storage.default_key", AccountDataEventType}
	AccountDataSecretStorageKey        = Type{"m.secret_storage.key", AccountDataEventType}
	AccountDataCrossSigningMaster      = Type{string(id.SecretXSMaster), AccountDataEventType}
	AccountDataCrossSigningUser        = Type{string(id.SecretXSUserSigning), AccountDataEventType}
	AccountDataCrossSigningSelf        = Type{string(id.SecretXSSelfSigning), AccountDataEventType}
	AccountDataMegolmBackupKey         = Type{string(id.SecretMegolmBackupV1), 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}
	ToDeviceSecretRequest    = Type{"m.secret.request", ToDeviceEventType}
	ToDeviceSecretSend       = Type{"m.secret.send", ToDeviceEventType}
	ToDeviceDummy            = Type{"m.dummy", ToDeviceEventType}

	ToDeviceVerificationRequest = Type{"m.key.verification.request", ToDeviceEventType}
	ToDeviceVerificationReady   = Type{"m.key.verification.ready", ToDeviceEventType}
	ToDeviceVerificationStart   = Type{"m.key.verification.start", ToDeviceEventType}
	ToDeviceVerificationDone    = Type{"m.key.verification.done", ToDeviceEventType}
	ToDeviceVerificationCancel  = Type{"m.key.verification.cancel", ToDeviceEventType}

	// SAS Verification Events
	ToDeviceVerificationAccept = Type{"m.key.verification.accept", ToDeviceEventType}
	ToDeviceVerificationKey    = Type{"m.key.verification.key", ToDeviceEventType}
	ToDeviceVerificationMAC    = Type{"m.key.verification.mac", ToDeviceEventType}

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

	ToDeviceBeeperRoomKeyAck = Type{"com.beeper.room_key.ack", ToDeviceEventType}
)

Device-to-device events

View Source
var ErrContentAlreadyParsed = errors.New("content is already parsed")
View Source
var ErrUnsupportedContentType = errors.New("unsupported event type")
View Source
var HTMLReplyFallbackRegex = regexp.MustCompile(`^<mx-reply>[\s\S]+?</mx-reply>`)
View Source
var MutedForever = time.Date(9999, 12, 31, 23, 59, 59, 999999999, time.UTC)
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{}),
	StateServerACL:         reflect.TypeOf(ServerACLEventContent{}),
	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{}),
	StatePolicyRoom:        reflect.TypeOf(ModPolicyContent{}),
	StatePolicyServer:      reflect.TypeOf(ModPolicyContent{}),
	StatePolicyUser:        reflect.TypeOf(ModPolicyContent{}),
	StateEncryption:        reflect.TypeOf(EncryptionEventContent{}),
	StateBridge:            reflect.TypeOf(BridgeEventContent{}),
	StateHalfShotBridge:    reflect.TypeOf(BridgeEventContent{}),
	StateSpaceParent:       reflect.TypeOf(SpaceParentEventContent{}),
	StateSpaceChild:        reflect.TypeOf(SpaceChildEventContent{}),
	StateInsertionMarker:   reflect.TypeOf(InsertionMarkerContent{}),

	StateLegacyPolicyRoom:     reflect.TypeOf(ModPolicyContent{}),
	StateLegacyPolicyServer:   reflect.TypeOf(ModPolicyContent{}),
	StateLegacyPolicyUser:     reflect.TypeOf(ModPolicyContent{}),
	StateUnstablePolicyRoom:   reflect.TypeOf(ModPolicyContent{}),
	StateUnstablePolicyServer: reflect.TypeOf(ModPolicyContent{}),
	StateUnstablePolicyUser:   reflect.TypeOf(ModPolicyContent{}),

	StateElementFunctionalMembers: reflect.TypeOf(ElementFunctionalMembersContent{}),

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

	EventUnstablePollStart:    reflect.TypeOf(PollStartEventContent{}),
	EventUnstablePollResponse: reflect.TypeOf(PollResponseEventContent{}),

	BeeperMessageStatus: reflect.TypeOf(BeeperMessageStatusEventContent{}),

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

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

	InRoomVerificationReady:  reflect.TypeOf(VerificationReadyEventContent{}),
	InRoomVerificationStart:  reflect.TypeOf(VerificationStartEventContent{}),
	InRoomVerificationDone:   reflect.TypeOf(VerificationDoneEventContent{}),
	InRoomVerificationCancel: reflect.TypeOf(VerificationCancelEventContent{}),

	InRoomVerificationAccept: reflect.TypeOf(VerificationAcceptEventContent{}),
	InRoomVerificationKey:    reflect.TypeOf(VerificationKeyEventContent{}),
	InRoomVerificationMAC:    reflect.TypeOf(VerificationMACEventContent{}),

	ToDeviceRoomKey:          reflect.TypeOf(RoomKeyEventContent{}),
	ToDeviceForwardedRoomKey: reflect.TypeOf(ForwardedRoomKeyEventContent{}),
	ToDeviceRoomKeyRequest:   reflect.TypeOf(RoomKeyRequestEventContent{}),
	ToDeviceEncrypted:        reflect.TypeOf(EncryptedEventContent{}),
	ToDeviceRoomKeyWithheld:  reflect.TypeOf(RoomKeyWithheldEventContent{}),
	ToDeviceSecretRequest:    reflect.TypeOf(SecretRequestEventContent{}),
	ToDeviceSecretSend:       reflect.TypeOf(SecretSendEventContent{}),
	ToDeviceDummy:            reflect.TypeOf(DummyEventContent{}),

	ToDeviceVerificationRequest: reflect.TypeOf(VerificationRequestEventContent{}),
	ToDeviceVerificationReady:   reflect.TypeOf(VerificationReadyEventContent{}),
	ToDeviceVerificationStart:   reflect.TypeOf(VerificationStartEventContent{}),
	ToDeviceVerificationDone:    reflect.TypeOf(VerificationDoneEventContent{}),
	ToDeviceVerificationCancel:  reflect.TypeOf(VerificationCancelEventContent{}),

	ToDeviceVerificationAccept: reflect.TypeOf(VerificationAcceptEventContent{}),
	ToDeviceVerificationKey:    reflect.TypeOf(VerificationKeyEventContent{}),
	ToDeviceVerificationMAC:    reflect.TypeOf(VerificationMACEventContent{}),

	ToDeviceOrgMatrixRoomKeyWithheld: reflect.TypeOf(RoomKeyWithheldEventContent{}),

	ToDeviceBeeperRoomKeyAck: reflect.TypeOf(BeeperRoomKeyAckEventContent{}),

	CallInvite:       reflect.TypeOf(CallInviteEventContent{}),
	CallCandidates:   reflect.TypeOf(CallCandidatesEventContent{}),
	CallAnswer:       reflect.TypeOf(CallAnswerEventContent{}),
	CallReject:       reflect.TypeOf(CallRejectEventContent{}),
	CallSelectAnswer: reflect.TypeOf(CallSelectAnswerEventContent{}),
	CallNegotiate:    reflect.TypeOf(CallNegotiateEventContent{}),
	CallHangup:       reflect.TypeOf(CallHangupEventContent{}),
}

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.

Functions

func CastOrDefault added in v0.20.0

func CastOrDefault[T any](content *Content) *T

func IsUnsupportedContentType deprecated

func IsUnsupportedContentType(err error) bool

Deprecated: use errors.Is directly

func ReverseTextToHTML added in v0.16.2

func ReverseTextToHTML(input string) string

ReverseTextToHTML reverses the modifications made by TextToHTML, i.e. replaces <br/> tags with newlines and unescapes HTML escape codes. For actually parsing HTML, use the format package instead.

func TextToHTML added in v0.12.3

func TextToHTML(text string) string

TextToHTML converts the given text to a HTML-safe representation by escaping HTML characters and replacing newlines with <br/> tags.

func TrimReplyFallbackHTML

func TrimReplyFallbackHTML(html string) string

func TrimReplyFallbackText

func TrimReplyFallbackText(text string) string

Types

type AnnotationChunk

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

func (*AnnotationChunk) Serialize

func (ac *AnnotationChunk) Serialize() RelationChunk

func (*AnnotationChunk) UnmarshalJSON

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

type BaseCallEventContent added in v0.9.7

type BaseCallEventContent struct {
	CallID  string      `json:"call_id"`
	PartyID string      `json:"party_id"`
	Version CallVersion `json:"version"`
}

type BeeperEncodedOrder added in v0.22.0

type BeeperEncodedOrder struct {
	// contains filtered or unexported fields
}

func BeeperEncodedOrderFromString added in v0.22.0

func BeeperEncodedOrderFromString(str string) (BeeperEncodedOrder, error)

func NewBeeperEncodedOrder added in v0.22.0

func NewBeeperEncodedOrder(order int64, suborder int64) BeeperEncodedOrder

func (BeeperEncodedOrder) IsZero added in v0.22.0

func (b BeeperEncodedOrder) IsZero() bool

func (BeeperEncodedOrder) MarshalJSON added in v0.22.0

func (b BeeperEncodedOrder) MarshalJSON() ([]byte, error)

func (BeeperEncodedOrder) OrderPair added in v0.22.0

func (b BeeperEncodedOrder) OrderPair() (int64, int64)

func (BeeperEncodedOrder) String added in v0.22.0

func (b BeeperEncodedOrder) String() string

func (*BeeperEncodedOrder) UnmarshalJSON added in v0.22.0

func (b *BeeperEncodedOrder) UnmarshalJSON(data []byte) error

type BeeperLinkPreview added in v0.18.0

type BeeperLinkPreview struct {
	LinkPreview

	MatchedURL      string             `json:"matched_url,omitempty"`
	ImageEncryption *EncryptedFileInfo `json:"beeper:image:encryption,omitempty"`
}

BeeperLinkPreview contains the data for a bundled URL preview as specified in MSC4095

https://github.com/matrix-org/matrix-spec-proposals/pull/4095

type BeeperMessageStatusEventContent added in v0.12.0

type BeeperMessageStatusEventContent struct {
	Network   string              `json:"network,omitempty"`
	RelatesTo RelatesTo           `json:"m.relates_to"`
	Status    MessageStatus       `json:"status"`
	Reason    MessageStatusReason `json:"reason,omitempty"`
	// Deprecated: clients were showing this to users even though they aren't supposed to.
	// Use InternalError for error messages that should be included in bug reports, but not shown in the UI.
	Error         string `json:"error,omitempty"`
	InternalError string `json:"internal_error,omitempty"`
	Message       string `json:"message,omitempty"`

	LastRetry id.EventID `json:"last_retry,omitempty"`

	MutateEventKey string `json:"mutate_event_key,omitempty"`

	// Indicates the set of users to whom the event was delivered. If nil, then
	// the client should not expect delivered status at any later point. If not
	// nil (even if empty), this field indicates which users the event was
	// delivered to.
	DeliveredToUsers *[]id.UserID `json:"delivered_to_users,omitempty"`
}

type BeeperMuteEventContent added in v0.20.0

type BeeperMuteEventContent struct {
	MutedUntil int64 `json:"muted_until,omitempty"`
}

func (*BeeperMuteEventContent) GetMutedUntilTime added in v0.20.0

func (bmec *BeeperMuteEventContent) GetMutedUntilTime() time.Time

func (*BeeperMuteEventContent) IsMuted added in v0.20.0

func (bmec *BeeperMuteEventContent) IsMuted() bool

type BeeperPerMessageProfile added in v0.20.0

type BeeperPerMessageProfile struct {
	ID          string               `json:"id"`
	Displayname string               `json:"displayname,omitempty"`
	AvatarURL   *id.ContentURIString `json:"avatar_url,omitempty"`
	AvatarFile  *EncryptedFileInfo   `json:"avatar_file,omitempty"`
}

type BeeperProfileExtra added in v0.19.0

type BeeperProfileExtra struct {
	RemoteID     string   `json:"com.beeper.bridge.remote_id,omitempty"`
	Identifiers  []string `json:"com.beeper.bridge.identifiers,omitempty"`
	Service      string   `json:"com.beeper.bridge.service,omitempty"`
	Network      string   `json:"com.beeper.bridge.network,omitempty"`
	IsBridgeBot  bool     `json:"com.beeper.bridge.is_bridge_bot,omitempty"`
	IsNetworkBot bool     `json:"com.beeper.bridge.is_network_bot,omitempty"`
}

type BeeperRetryMetadata added in v0.12.0

type BeeperRetryMetadata struct {
	OriginalEventID id.EventID `json:"original_event_id"`
	RetryCount      int        `json:"retry_count"`
}

type BeeperRoomKeyAckEventContent added in v0.15.1

type BeeperRoomKeyAckEventContent struct {
	RoomID            id.RoomID    `json:"room_id"`
	SessionID         id.SessionID `json:"session_id"`
	FirstMessageIndex int          `json:"first_message_index"`
}

type BridgeEventContent added in v0.9.29

type BridgeEventContent struct {
	BridgeBot id.UserID          `json:"bridgebot"`
	Creator   id.UserID          `json:"creator,omitempty"`
	Protocol  BridgeInfoSection  `json:"protocol"`
	Network   *BridgeInfoSection `json:"network,omitempty"`
	Channel   BridgeInfoSection  `json:"channel"`

	BeeperRoomType   string `json:"com.beeper.room_type,omitempty"`
	BeeperRoomTypeV2 string `json:"com.beeper.room_type.v2,omitempty"`
}

BridgeEventContent represents the content of a m.bridge state event. https://github.com/matrix-org/matrix-doc/pull/2346

type BridgeInfoSection added in v0.9.29

type BridgeInfoSection struct {
	ID          string              `json:"id"`
	DisplayName string              `json:"displayname,omitempty"`
	AvatarURL   id.ContentURIString `json:"avatar_url,omitempty"`
	ExternalURL string              `json:"external_url,omitempty"`

	Receiver string `json:"fi.mau.receiver,omitempty"`
}

type CallAnswerEventContent added in v0.9.7

type CallAnswerEventContent struct {
	BaseCallEventContent
	Answer CallData `json:"answer"`
}

type CallCandidate added in v0.9.7

type CallCandidate struct {
	Candidate     string `json:"candidate"`
	SDPMLineIndex int    `json:"sdpMLineIndex"`
	SDPMID        string `json:"sdpMid"`
}

type CallCandidatesEventContent added in v0.9.7

type CallCandidatesEventContent struct {
	BaseCallEventContent
	Candidates []CallCandidate `json:"candidates"`
}

type CallData added in v0.9.7

type CallData struct {
	SDP  string       `json:"sdp"`
	Type CallDataType `json:"type"`
}

type CallDataType added in v0.9.7

type CallDataType string
const (
	CallDataTypeOffer  CallDataType = "offer"
	CallDataTypeAnswer CallDataType = "answer"
)

type CallHangupEventContent added in v0.9.7

type CallHangupEventContent struct {
	BaseCallEventContent
	Reason CallHangupReason `json:"reason"`
}

type CallHangupReason added in v0.9.7

type CallHangupReason string
const (
	CallHangupICEFailed       CallHangupReason = "ice_failed"
	CallHangupInviteTimeout   CallHangupReason = "invite_timeout"
	CallHangupUserHangup      CallHangupReason = "user_hangup"
	CallHangupUserMediaFailed CallHangupReason = "user_media_failed"
	CallHangupUnknownError    CallHangupReason = "unknown_error"
)

type CallInviteEventContent added in v0.9.7

type CallInviteEventContent struct {
	BaseCallEventContent
	Lifetime int      `json:"lifetime"`
	Offer    CallData `json:"offer"`
}

type CallNegotiateEventContent added in v0.9.7

type CallNegotiateEventContent struct {
	BaseCallEventContent
	Lifetime    int      `json:"lifetime"`
	Description CallData `json:"description"`
}

type CallRejectEventContent added in v0.9.7

type CallRejectEventContent struct {
	BaseCallEventContent
}

type CallSelectAnswerEventContent added in v0.9.7

type CallSelectAnswerEventContent struct {
	BaseCallEventContent
	SelectedPartyID string `json:"selected_party_id"`
}

type CallVersion added in v0.9.11

type CallVersion string

func (*CallVersion) Int added in v0.9.11

func (cv *CallVersion) Int() (int, error)

func (*CallVersion) MarshalJSON added in v0.9.11

func (cv *CallVersion) MarshalJSON() ([]byte, error)

func (*CallVersion) UnmarshalJSON added in v0.9.11

func (cv *CallVersion) UnmarshalJSON(raw []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://spec.matrix.org/v1.2/client-server-api/#mroomcanonical_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 raw JSON bytes are stored in VeryRaw and parsed into a map[string]interface{} in the Raw field. Additionally, you can call ParseRaw with the correct event type to parse the (VeryRaw) content into a nicer struct, which you can then access from Parsed or via the helper functions.

When being marshaled into JSON, the data in Parsed will be marshaled first and then recursively merged with the data in Raw. Values in Raw are preferred, but nested objects will be recursed into before merging, rather than overriding the whole object with the one in Raw). If one of them is nil, the only the other is used. If both (Parsed and Raw) are nil, VeryRaw is used instead.

func (*Content) AsBridge added in v0.9.29

func (content *Content) AsBridge() *BridgeEventContent

func (*Content) AsCallAnswer added in v0.9.7

func (content *Content) AsCallAnswer() *CallAnswerEventContent

func (*Content) AsCallCandidates added in v0.9.7

func (content *Content) AsCallCandidates() *CallCandidatesEventContent

func (*Content) AsCallHangup added in v0.9.7

func (content *Content) AsCallHangup() *CallHangupEventContent

func (*Content) AsCallInvite added in v0.9.7

func (content *Content) AsCallInvite() *CallInviteEventContent

func (*Content) AsCallNegotiate added in v0.9.7

func (content *Content) AsCallNegotiate() *CallNegotiateEventContent

func (*Content) AsCallReject added in v0.9.7

func (content *Content) AsCallReject() *CallRejectEventContent

func (*Content) AsCallSelectAnswer added in v0.9.7

func (content *Content) AsCallSelectAnswer() *CallSelectAnswerEventContent

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) AsElementFunctionalMembers added in v0.19.0

func (content *Content) AsElementFunctionalMembers() *ElementFunctionalMembersContent

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) AsMarkedUnread added in v0.19.0

func (content *Content) AsMarkedUnread() *MarkedUnreadEventContent

func (*Content) AsMember

func (content *Content) AsMember() *MemberEventContent

func (*Content) AsMessage

func (content *Content) AsMessage() *MessageEventContent

func (*Content) AsModPolicy added in v0.10.12

func (content *Content) AsModPolicy() *ModPolicyContent

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) AsSpaceChild added in v0.10.8

func (content *Content) AsSpaceChild() *SpaceChildEventContent

func (*Content) AsSpaceParent added in v0.10.8

func (content *Content) AsSpaceParent() *SpaceParentEventContent

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) AsVerificationAccept added in v0.18.0

func (content *Content) AsVerificationAccept() *VerificationAcceptEventContent

func (*Content) AsVerificationCancel added in v0.18.0

func (content *Content) AsVerificationCancel() *VerificationCancelEventContent

func (*Content) AsVerificationDone added in v0.18.0

func (content *Content) AsVerificationDone() *VerificationDoneEventContent

func (*Content) AsVerificationKey added in v0.18.0

func (content *Content) AsVerificationKey() *VerificationKeyEventContent

func (*Content) AsVerificationMAC added in v0.18.0

func (content *Content) AsVerificationMAC() *VerificationMACEventContent

func (*Content) AsVerificationReady added in v0.18.0

func (content *Content) AsVerificationReady() *VerificationReadyEventContent

func (*Content) AsVerificationRequest added in v0.18.0

func (content *Content) AsVerificationRequest() *VerificationRequestEventContent

func (*Content) AsVerificationStart added in v0.18.0

func (content *Content) AsVerificationStart() *VerificationStartEventContent

func (*Content) GetRaw added in v0.22.0

func (content *Content) GetRaw() map[string]interface{}

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 {
	Type        RoomType     `json:"type,omitempty"`
	Creator     id.UserID    `json:"creator,omitempty"`
	Federate    bool         `json:"m.federate,omitempty"`
	RoomVersion RoomVersion  `json:"room_version,omitempty"`
	Predecessor *Predecessor `json:"predecessor,omitempty"`
}

CreateEventContent represents the content of a m.room.create state event. https://spec.matrix.org/v1.2/client-server-api/#mroomcreate

type DirectChatsEventContent

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

DirectChatsEventContent represents the content of a m.direct account data event. https://spec.matrix.org/v1.2/client-server-api/#mdirect

type DummyEventContent added in v0.10.5

type DummyEventContent struct{}

type ElementFunctionalMembersContent added in v0.19.0

type ElementFunctionalMembersContent struct {
	ServiceMembers []id.UserID `json:"service_members"`
}

type EncryptedEventContent

type EncryptedEventContent struct {
	Algorithm id.Algorithm `json:"algorithm"`
	SenderKey id.SenderKey `json:"sender_key,omitempty"`
	// Deprecated: Matrix v1.3
	DeviceID id.DeviceID `json:"device_id,omitempty"`
	// Only present for Megolm events
	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"`
	Mentions  *Mentions  `json:"m.mentions,omitempty"`
}

EncryptedEventContent represents the content of a m.room.encrypted message event. https://spec.matrix.org/v1.2/client-server-api/#mroomencrypted

Note that sender_key and device_id are deprecated in Megolm events as of https://github.com/matrix-org/matrix-spec-proposals/pull/3700

func (*EncryptedEventContent) MarshalJSON

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

func (*EncryptedEventContent) UnmarshalJSON

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

type EncryptedFileInfo

type EncryptedFileInfo struct {
	attachment.EncryptedFile
	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://spec.matrix.org/v1.2/client-server-api/#mroomencryption

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,omitempty"`           // The user ID of the sender of the event
	Type      Type       `json:"type"`                       // The event type
	Timestamp int64      `json:"origin_server_ts,omitempty"` // The unix timestamp when this message was sent by the origin server
	ID        id.EventID `json:"event_id,omitempty"`         // The unique ID of this event
	RoomID    id.RoomID  `json:"room_id,omitempty"`          // 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:"-"`

	ToUserID   id.UserID   `json:"to_user_id,omitempty"`   // The user ID that the to-device event was sent to. Only present in MSC2409 appservice transactions.
	ToDeviceID id.DeviceID `json:"to_device_id,omitempty"` // The device ID that the to-device event was sent to. Only present in MSC2409 appservice transactions.
}

Event represents a single Matrix event.

func (*Event) GetStateKey

func (evt *Event) GetStateKey() string

func (*Event) MarshalJSON added in v0.9.30

func (evt *Event) MarshalJSON() ([]byte, error)

MarshalJSON marshals the event, including omitting the unsigned field if it's empty.

This is necessary because Unsigned is not a pointer (for convenience reasons), and encoding/json doesn't know how to check if a non-pointer struct is empty.

TODO(tulir): maybe it makes more sense to make Unsigned a pointer and make an easy and safe way to access it?

func (*Event) UnmarshalJSON added in v0.10.0

func (evt *Event) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the event, including moving prev_content from the top level to inside unsigned.

type EventIDChunk

type EventIDChunk struct {
	RelationChunk
	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"`

	Blurhash     string `json:"blurhash,omitempty"`
	AnoaBlurhash string `json:"xyz.amorgan.blurhash,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://spec.matrix.org/v1.2/client-server-api/#mroommessage-msgtypes

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

Message formats

type ForwardedRoomKeyEventContent

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

	MaxAge      int64 `json:"com.beeper.max_age_ms"`
	MaxMessages int   `json:"com.beeper.max_messages"`
	IsScheduled bool  `json:"com.beeper.is_scheduled"`
}

ForwardedRoomKeyEventContent represents the content of a m.forwarded_room_key to_device event. https://spec.matrix.org/v1.2/client-server-api/#mforwarded_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://spec.matrix.org/v1.2/client-server-api/#mfully_read

type GuestAccess

type GuestAccess string

GuestAccess specifies whether or not guest accounts can join. https://spec.matrix.org/v1.2/client-server-api/#mroomguest_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://spec.matrix.org/v1.2/client-server-api/#mroomguest_access

type HistoryVisibility

type HistoryVisibility string

HistoryVisibility specifies who can see new messages. https://spec.matrix.org/v1.2/client-server-api/#mroomhistory_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://spec.matrix.org/v1.2/client-server-api/#mroomhistory_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://spec.matrix.org/v1.2/client-server-api/#mignored_user_list

type InReplyTo added in v0.12.0

type InReplyTo struct {
	EventID id.EventID `json:"event_id,omitempty"`

	UnstableRoomID id.RoomID `json:"room_id,omitempty"`
}

type InRoomVerificationEvent added in v0.18.0

type InRoomVerificationEvent struct {
	// RelatesTo indicates the m.key.verification.request that this message is
	// related to. Note that for encrypted messages, this property should be in
	// the unencrypted portion of the event.
	RelatesTo *RelatesTo `json:"m.relates_to,omitempty"`
}

InRoomVerificationEvent contains the fields common to all in-room verification events.

func (*InRoomVerificationEvent) GetRelatesTo added in v0.18.0

func (ve *InRoomVerificationEvent) GetRelatesTo() *RelatesTo

func (*InRoomVerificationEvent) OptionalGetRelatesTo added in v0.18.0

func (ve *InRoomVerificationEvent) OptionalGetRelatesTo() *RelatesTo

func (*InRoomVerificationEvent) SetRelatesTo added in v0.18.0

func (ve *InRoomVerificationEvent) SetRelatesTo(rel *RelatesTo)

type InsertionMarkerContent deprecated added in v0.12.0

type InsertionMarkerContent struct {
	InsertionID id.EventID `json:"org.matrix.msc2716.marker.insertion"`
	Timestamp   int64      `json:"com.beeper.timestamp,omitempty"`
}

Deprecated: MSC2716 has been abandoned

type JoinRule

type JoinRule string

JoinRule specifies how open a room is to new members. https://spec.matrix.org/v1.2/client-server-api/#mroomjoin_rules

const (
	JoinRulePublic          JoinRule = "public"
	JoinRuleKnock           JoinRule = "knock"
	JoinRuleInvite          JoinRule = "invite"
	JoinRuleRestricted      JoinRule = "restricted"
	JoinRuleKnockRestricted JoinRule = "knock_restricted"
	JoinRulePrivate         JoinRule = "private"
)

type JoinRuleAllow added in v0.11.0

type JoinRuleAllow struct {
	RoomID id.RoomID         `json:"room_id"`
	Type   JoinRuleAllowType `json:"type"`
}

type JoinRuleAllowType added in v0.11.0

type JoinRuleAllowType string
const (
	JoinRuleAllowRoomMembership JoinRuleAllowType = "m.room_membership"
)

type JoinRulesEventContent

type JoinRulesEventContent struct {
	JoinRule JoinRule        `json:"join_rule"`
	Allow    []JoinRuleAllow `json:"allow,omitempty"`
}

JoinRulesEventContent represents the content of a m.room.join_rules state event. https://spec.matrix.org/v1.2/client-server-api/#mroomjoin_rules

type KeyAgreementProtocol added in v0.7.0

type KeyAgreementProtocol string
const (
	KeyAgreementProtocolCurve25519           KeyAgreementProtocol = "curve25519"
	KeyAgreementProtocolCurve25519HKDFSHA256 KeyAgreementProtocol = "curve25519-hkdf-sha256"
)

type KeyRequestAction

type KeyRequestAction string

type LinkPreview added in v0.18.0

type LinkPreview struct {
	CanonicalURL string `json:"og:url,omitempty"`
	Title        string `json:"og:title,omitempty"`
	Type         string `json:"og:type,omitempty"`
	Description  string `json:"og:description,omitempty"`

	ImageURL id.ContentURIString `json:"og:image,omitempty"`

	ImageSize   int    `json:"matrix:image:size,omitempty"`
	ImageWidth  int    `json:"og:image:width,omitempty"`
	ImageHeight int    `json:"og:image:height,omitempty"`
	ImageType   string `json:"og:image:type,omitempty"`
}

type MACMethod added in v0.7.0

type MACMethod string
const (
	MACMethodHKDFHMACSHA256   MACMethod = "hkdf-hmac-sha256"
	MACMethodHKDFHMACSHA256V2 MACMethod = "hkdf-hmac-sha256.v2"
)

type MSC1767Audio added in v0.19.0

type MSC1767Audio struct {
	Duration int   `json:"duration"`
	Waveform []int `json:"waveform"`
}

func (*MSC1767Audio) MarshalJSON added in v0.21.0

func (ma *MSC1767Audio) MarshalJSON() ([]byte, error)

type MSC1767Message added in v0.21.1

type MSC1767Message struct {
	Text    string `json:"org.matrix.msc1767.text,omitempty"`
	HTML    string `json:"org.matrix.msc1767.html,omitempty"`
	Message []struct {
		MimeType string `json:"mimetype"`
		Body     string `json:"body"`
	} `json:"org.matrix.msc1767.message,omitempty"`
}

type MSC3245Voice added in v0.19.0

type MSC3245Voice struct{}

type MarkedUnreadEventContent added in v0.19.0

type MarkedUnreadEventContent struct {
	Unread bool `json:"unread"`
}

type MautrixInfo added in v0.4.7

type MautrixInfo struct {
	EventSource Source

	TrustState    id.TrustState
	ForwardedKeys bool
	WasEncrypted  bool
	TrustSource   *id.Device

	ReceivedAt         time.Time
	EditedAt           time.Time
	LastEditID         id.EventID
	DecryptionDuration time.Duration

	CheckpointSent 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://spec.matrix.org/v1.2/client-server-api/#mroommember

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 Mentions added in v0.15.0

type Mentions struct {
	UserIDs []id.UserID `json:"user_ids,omitempty"`
	Room    bool        `json:"room,omitempty"`
}

func (*Mentions) Add added in v0.19.0

func (m *Mentions) Add(userID id.UserID)

func (*Mentions) Has added in v0.21.1

func (m *Mentions) Has(userID id.UserID) bool

type MessageEventContent

type MessageEventContent struct {
	// Base m.room.message fields
	MsgType MessageType `json:"msgtype,omitempty"`
	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"`

	FileName string `json:"filename,omitempty"`

	Mentions *Mentions `json:"m.mentions,omitempty"`

	// Edits and relations
	NewContent *MessageEventContent `json:"m.new_content,omitempty"`
	RelatesTo  *RelatesTo           `json:"m.relates_to,omitempty"`

	// In-room verification
	To         id.UserID            `json:"to,omitempty"`
	FromDevice id.DeviceID          `json:"from_device,omitempty"`
	Methods    []VerificationMethod `json:"methods,omitempty"`

	MessageSendRetry         *BeeperRetryMetadata     `json:"com.beeper.message_send_retry,omitempty"`
	BeeperGalleryImages      []*MessageEventContent   `json:"com.beeper.gallery.images,omitempty"`
	BeeperGalleryCaption     string                   `json:"com.beeper.gallery.caption,omitempty"`
	BeeperGalleryCaptionHTML string                   `json:"com.beeper.gallery.caption_html,omitempty"`
	BeeperPerMessageProfile  *BeeperPerMessageProfile `json:"com.beeper.per_message_profile,omitempty"`

	BeeperLinkPreviews []*BeeperLinkPreview `json:"com.beeper.linkpreviews,omitempty"`

	MSC1767Audio *MSC1767Audio `json:"org.matrix.msc1767.audio,omitempty"`
	MSC3245Voice *MSC3245Voice `json:"org.matrix.msc3245.voice,omitempty"`
	// contains filtered or unexported fields
}

MessageEventContent 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.

https://spec.matrix.org/v1.2/client-server-api/#mroommessage

func (*MessageEventContent) EnsureHasHTML added in v0.11.0

func (content *MessageEventContent) EnsureHasHTML()

func (*MessageEventContent) GetCaption added in v0.21.1

func (content *MessageEventContent) GetCaption() string

func (*MessageEventContent) GetFile

func (content *MessageEventContent) GetFile() *EncryptedFileInfo

func (*MessageEventContent) GetFileName added in v0.21.1

func (content *MessageEventContent) GetFileName() string

func (*MessageEventContent) GetFormattedCaption added in v0.21.1

func (content *MessageEventContent) GetFormattedCaption() string

func (*MessageEventContent) GetInfo

func (content *MessageEventContent) GetInfo() *FileInfo

func (*MessageEventContent) GetRelatesTo

func (content *MessageEventContent) GetRelatesTo() *RelatesTo

func (*MessageEventContent) GetReplyTo deprecated

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

Deprecated: RelatesTo methods are nil-safe, so RelatesTo.GetReplyTo can be used directly

func (*MessageEventContent) OptionalGetRelatesTo

func (content *MessageEventContent) OptionalGetRelatesTo() *RelatesTo

func (*MessageEventContent) RemoveReplyFallback

func (content *MessageEventContent) RemoveReplyFallback()

func (*MessageEventContent) SetEdit added in v0.9.31

func (content *MessageEventContent) SetEdit(original id.EventID)

func (*MessageEventContent) SetRelatesTo

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

func (*MessageEventContent) SetReply

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

type MessageStatus added in v0.12.0

type MessageStatus string
const (
	MessageStatusSuccess   MessageStatus = "SUCCESS"
	MessageStatusPending   MessageStatus = "PENDING"
	MessageStatusRetriable MessageStatus = "FAIL_RETRIABLE"
	MessageStatusFail      MessageStatus = "FAIL_PERMANENT"
)

type MessageStatusReason added in v0.12.0

type MessageStatusReason string
const (
	MessageStatusGenericError      MessageStatusReason = "m.event_not_handled"
	MessageStatusUnsupported       MessageStatusReason = "com.beeper.unsupported_event"
	MessageStatusUndecryptable     MessageStatusReason = "com.beeper.undecryptable_event"
	MessageStatusTooOld            MessageStatusReason = "m.event_too_old"
	MessageStatusNetworkError      MessageStatusReason = "m.foreign_network_error"
	MessageStatusNoPermission      MessageStatusReason = "m.no_permission"
	MessageStatusBridgeUnavailable MessageStatusReason = "m.bridge_unavailable"
)

type MessageType

type MessageType string

MessageType is the sub-type of a m.room.message event. https://spec.matrix.org/v1.2/client-server-api/#mroommessage-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"

	MsgVerificationRequest MessageType = "m.key.verification.request"

	MsgBeeperGallery MessageType = "com.beeper.gallery"
)

Msgtypes

func (MessageType) IsMedia added in v0.19.0

func (mt MessageType) IsMedia() bool

func (MessageType) IsText added in v0.19.0

func (mt MessageType) IsText() bool

type ModPolicyContent added in v0.10.10

type ModPolicyContent struct {
	Entity         string               `json:"entity"`
	Reason         string               `json:"reason"`
	Recommendation PolicyRecommendation `json:"recommendation"`
}

ModPolicyContent represents the content of a m.room.rule.user, m.room.rule.room, and m.room.rule.server state event. https://spec.matrix.org/v1.2/client-server-api/#moderation-policy-lists

type NotificationPowerLevels added in v0.14.0

type NotificationPowerLevels struct {
	RoomPtr *int `json:"room,omitempty"`
}

func (*NotificationPowerLevels) Clone added in v0.15.1

func (*NotificationPowerLevels) Room added in v0.14.0

func (npl *NotificationPowerLevels) Room() int

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://spec.matrix.org/v1.2/client-server-api/#mroompinned_events

type PolicyRecommendation added in v0.21.0

type PolicyRecommendation string
const (
	PolicyRecommendationBan         PolicyRecommendation = "m.ban"
	PolicyRecommendationUnstableBan PolicyRecommendation = "org.matrix.mjolnir.ban"
	PolicyRecommendationUnban       PolicyRecommendation = "fi.mau.meowlnir.unban"
)

type PollResponseEventContent added in v0.21.1

type PollResponseEventContent struct {
	RelatesTo RelatesTo `json:"m.relates_to"`
	Response  struct {
		Answers []string `json:"answers"`
	} `json:"org.matrix.msc3381.poll.response"`
}

func (*PollResponseEventContent) GetRelatesTo added in v0.21.1

func (content *PollResponseEventContent) GetRelatesTo() *RelatesTo

func (*PollResponseEventContent) OptionalGetRelatesTo added in v0.21.1

func (content *PollResponseEventContent) OptionalGetRelatesTo() *RelatesTo

func (*PollResponseEventContent) SetRelatesTo added in v0.21.1

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

type PollStartEventContent added in v0.21.1

type PollStartEventContent struct {
	RelatesTo *RelatesTo `json:"m.relates_to"`
	Mentions  *Mentions  `json:"m.mentions,omitempty"`
	PollStart struct {
		Kind          string         `json:"kind"`
		MaxSelections int            `json:"max_selections"`
		Question      MSC1767Message `json:"question"`
		Answers       []struct {
			ID string `json:"id"`
			MSC1767Message
		} `json:"answers"`
	} `json:"org.matrix.msc3381.poll.start"`
}

func (*PollStartEventContent) GetRelatesTo added in v0.21.1

func (content *PollStartEventContent) GetRelatesTo() *RelatesTo

func (*PollStartEventContent) OptionalGetRelatesTo added in v0.21.1

func (content *PollStartEventContent) OptionalGetRelatesTo() *RelatesTo

func (*PollStartEventContent) SetRelatesTo added in v0.21.1

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

type PowerLevelsEventContent

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

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

	Notifications *NotificationPowerLevels `json:"notifications,omitempty"`

	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://spec.matrix.org/v1.5/client-server-api/#mroompower_levels

func (*PowerLevelsEventContent) Ban

func (pl *PowerLevelsEventContent) Ban() int

func (*PowerLevelsEventContent) Clone added in v0.15.1

func (*PowerLevelsEventContent) EnsureEventLevel

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

func (*PowerLevelsEventContent) EnsureEventLevelAs added in v0.20.0

func (pl *PowerLevelsEventContent) EnsureEventLevelAs(actor id.UserID, eventType Type, level int) bool

func (*PowerLevelsEventContent) EnsureUserLevel

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

func (*PowerLevelsEventContent) EnsureUserLevelAs added in v0.20.0

func (pl *PowerLevelsEventContent) EnsureUserLevelAs(actor, target 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 Predecessor added in v0.12.0

type Predecessor struct {
	RoomID  id.RoomID  `json:"room_id"`
	EventID id.EventID `json:"event_id"`
}

type Presence

type Presence string
const (
	PresenceOnline      Presence = "online"
	PresenceOffline     Presence = "offline"
	PresenceUnavailable Presence = "unavailable"
)

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://spec.matrix.org/v1.2/client-server-api/#mpresence

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 time.Time

	// Thread ID for thread-specific read receipts from MSC3771
	ThreadID ThreadID

	// Extra contains any unknown fields in the read receipt event.
	// Most servers don't allow clients to set them, so this will be empty in most cases.
	Extra map[string]interface{}
}

func (ReadReceipt) MarshalJSON added in v0.12.2

func (rr ReadReceipt) MarshalJSON() ([]byte, error)

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://spec.matrix.org/v1.2/client-server-api/#mreceipt

func (ReceiptEventContent) GetOrCreate added in v0.12.0

func (rec ReceiptEventContent) GetOrCreate(evt id.EventID) Receipts

func (ReceiptEventContent) Set added in v0.12.0

func (rec ReceiptEventContent) Set(evtID id.EventID, receiptType ReceiptType, userID id.UserID, receipt ReadReceipt)

type ReceiptType added in v0.12.0

type ReceiptType string
const (
	ReceiptTypeRead        ReceiptType = "m.read"
	ReceiptTypeReadPrivate ReceiptType = "m.read.private"
)

type Receipts

type Receipts map[ReceiptType]UserReceipts

func (Receipts) GetOrCreate added in v0.12.0

func (rps Receipts) GetOrCreate(receiptType ReceiptType) UserReceipts

type RedactionEventContent

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

	// The event ID is here as of room v11. In old servers it may only be at the top level.
	Redacts id.EventID `json:"redacts,omitempty"`
}

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

https://spec.matrix.org/v1.8/client-server-api/#mroomredaction

type Relatable

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

type RelatesTo

type RelatesTo struct {
	Type    RelationType `json:"rel_type,omitempty"`
	EventID id.EventID   `json:"event_id,omitempty"`
	Key     string       `json:"key,omitempty"`

	InReplyTo     *InReplyTo `json:"m.in_reply_to,omitempty"`
	IsFallingBack bool       `json:"is_falling_back,omitempty"`
}

func (*RelatesTo) Copy added in v0.12.0

func (rel *RelatesTo) Copy() *RelatesTo

func (*RelatesTo) GetAnnotationID

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

func (*RelatesTo) GetAnnotationKey

func (rel *RelatesTo) GetAnnotationKey() string

func (*RelatesTo) GetNonFallbackReplyTo added in v0.12.3

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

func (*RelatesTo) GetReferenceID

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

func (*RelatesTo) GetReplaceID

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

func (*RelatesTo) GetReplyTo added in v0.12.0

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

func (*RelatesTo) GetThreadParent added in v0.12.0

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

func (*RelatesTo) SetAnnotation added in v0.12.0

func (rel *RelatesTo) SetAnnotation(mxid id.EventID, key string) *RelatesTo

func (*RelatesTo) SetReplace added in v0.12.0

func (rel *RelatesTo) SetReplace(mxid id.EventID) *RelatesTo

func (*RelatesTo) SetReplyTo added in v0.12.0

func (rel *RelatesTo) SetReplyTo(mxid id.EventID) *RelatesTo

func (*RelatesTo) SetThread added in v0.12.0

func (rel *RelatesTo) SetThread(mxid, fallback id.EventID) *RelatesTo

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"
	RelThread     RelationType = "m.thread"
)

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.ContentURIString `json:"url,omitempty"`
	Info        *FileInfo           `json:"info,omitempty"`
	MSC3414File *EncryptedFileInfo  `json:"org.matrix.msc3414.file,omitempty"`
}

RoomAvatarEventContent represents the content of a m.room.avatar state event. https://spec.matrix.org/v1.2/client-server-api/#mroomavatar

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"`

	MaxAge      int64 `json:"com.beeper.max_age_ms"`
	MaxMessages int   `json:"com.beeper.max_messages"`
	IsScheduled bool  `json:"com.beeper.is_scheduled"`
}

RoomKeyEventContent represents the content of a m.room_key to_device event. https://spec.matrix.org/v1.2/client-server-api/#mroom_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://spec.matrix.org/v1.2/client-server-api/#mroom_key_request

type RoomKeyWithheldCode added in v0.5.3

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

	RoomKeyWithheldBeeperRedacted RoomKeyWithheldCode = "com.beeper.redacted"
)

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"`
}

func (*RoomKeyWithheldEventContent) Error added in v0.15.2

func (withheld *RoomKeyWithheldEventContent) Error() string

func (*RoomKeyWithheldEventContent) Is added in v0.15.2

func (withheld *RoomKeyWithheldEventContent) Is(other error) bool

type RoomNameEventContent

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

RoomNameEventContent represents the content of a m.room.name state event. https://spec.matrix.org/v1.2/client-server-api/#mroomname

type RoomTag added in v0.19.0

type RoomTag string
const (
	RoomTagFavourite    RoomTag = "m.favourite"
	RoomTagLowPriority  RoomTag = "m.lowpriority"
	RoomTagServerNotice RoomTag = "m.server_notice"
)

func (RoomTag) IsUserDefined added in v0.19.0

func (rt RoomTag) IsUserDefined() bool

func (RoomTag) Name added in v0.19.0

func (rt RoomTag) Name() string

func (RoomTag) String added in v0.19.0

func (rt RoomTag) String() string

type RoomType added in v0.10.8

type RoomType string
const (
	RoomTypeDefault RoomType = ""
	RoomTypeSpace   RoomType = "m.space"
)

type RoomVersion added in v0.19.0

type RoomVersion string
const (
	RoomV1  RoomVersion = "1"
	RoomV2  RoomVersion = "2"
	RoomV3  RoomVersion = "3"
	RoomV4  RoomVersion = "4"
	RoomV5  RoomVersion = "5"
	RoomV6  RoomVersion = "6"
	RoomV7  RoomVersion = "7"
	RoomV8  RoomVersion = "8"
	RoomV9  RoomVersion = "9"
	RoomV10 RoomVersion = "10"
	RoomV11 RoomVersion = "11"
)

type SASMethod added in v0.7.0

type SASMethod string
const (
	SASMethodDecimal SASMethod = "decimal"
	SASMethodEmoji   SASMethod = "emoji"
)

type SecretRequestAction added in v0.18.0

type SecretRequestAction string

func (SecretRequestAction) String added in v0.18.0

func (a SecretRequestAction) String() string

type SecretRequestEventContent added in v0.18.0

type SecretRequestEventContent struct {
	Name               id.Secret           `json:"name,omitempty"`
	Action             SecretRequestAction `json:"action"`
	RequestingDeviceID id.DeviceID         `json:"requesting_device_id"`
	RequestID          string              `json:"request_id"`
}

type SecretSendEventContent added in v0.18.0

type SecretSendEventContent struct {
	RequestID string `json:"request_id"`
	Secret    string `json:"secret"`
}

type ServerACLEventContent added in v0.10.10

type ServerACLEventContent struct {
	Allow           []string `json:"allow,omitempty"`
	AllowIPLiterals bool     `json:"allow_ip_literals"`
	Deny            []string `json:"deny,omitempty"`
}

ServerACLEventContent represents the content of a m.room.server_acl state event. https://spec.matrix.org/v1.2/client-server-api/#server-access-control-lists-acls-for-rooms

type Source added in v0.17.0

type Source int

Source represents the part of the sync response that an event came from.

const (
	SourcePresence Source = 1 << iota
	SourceJoin
	SourceInvite
	SourceLeave
	SourceAccountData
	SourceTimeline
	SourceState
	SourceEphemeral
	SourceToDevice
	SourceDecrypted
)

func (Source) String added in v0.17.0

func (es Source) String() string

type SpaceChildEventContent added in v0.10.8

type SpaceChildEventContent struct {
	Via       []string `json:"via,omitempty"`
	Order     string   `json:"order,omitempty"`
	Suggested bool     `json:"suggested,omitempty"`
}

type SpaceParentEventContent added in v0.10.8

type SpaceParentEventContent struct {
	Via       []string `json:"via,omitempty"`
	Canonical bool     `json:"canonical,omitempty"`
}

type StrippedState

type StrippedState struct {
	Content  Content   `json:"content"`
	Type     Type      `json:"type"`
	StateKey string    `json:"state_key"`
	Sender   id.UserID `json:"sender"`
}

type Tag deprecated

type Tag = TagMetadata

Deprecated: type alias

type TagEventContent

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

TagEventContent represents the content of a m.tag room account data event. https://spec.matrix.org/v1.2/client-server-api/#mtag

type TagMetadata added in v0.19.0

type TagMetadata struct {
	Order json.Number `json:"order,omitempty"`

	MauDoublePuppetSource string `json:"fi.mau.double_puppet_source,omitempty"`
}

type Tags

type Tags map[RoomTag]TagMetadata

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 ThreadID added in v0.12.2

type ThreadID = id.EventID
const ReadReceiptThreadMain ThreadID = "main"

type ToDeviceVerificationEvent added in v0.18.0

type ToDeviceVerificationEvent struct {
	// TransactionID is an opaque identifier for the verification request. Must
	// be unique with respect to the devices involved.
	TransactionID id.VerificationTransactionID `json:"transaction_id,omitempty"`
}

ToDeviceVerificationEvent contains the fields common to all to-device verification events.

func (*ToDeviceVerificationEvent) GetTransactionID added in v0.18.0

func (*ToDeviceVerificationEvent) SetTransactionID added in v0.18.0

func (ve *ToDeviceVerificationEvent) SetTransactionID(id id.VerificationTransactionID)

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://spec.matrix.org/v1.2/client-server-api/#mroomtombstone

type TopicEventContent

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

TopicEventContent represents the content of a m.room.topic state event. https://spec.matrix.org/v1.2/client-server-api/#mroomtopic

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) IsCall added in v0.9.7

func (et *Type) IsCall() bool

func (*Type) IsCustom

func (et *Type) IsCustom() bool

func (*Type) IsEphemeral

func (et *Type) IsEphemeral() bool

func (*Type) IsInRoomVerification added in v0.8.0

func (et *Type) IsInRoomVerification() 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 (
	// Unknown events
	UnknownEventType TypeClass = iota
	// Normal message events
	MessageEventType
	// State events
	StateEventType
	// Ephemeral events
	EphemeralEventType
	// Account data events
	AccountDataEventType
	// Device-to-device events
	ToDeviceEventType
)

func (TypeClass) Name

func (tc TypeClass) Name() string

type TypingEventContent

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

TypingEventContent represents the content of a m.typing ephemeral event. https://spec.matrix.org/v1.2/client-server-api/#mtyping

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,omitempty"`

	BeeperHSOrder       int64              `json:"com.beeper.hs.order,omitempty"`
	BeeperHSSuborder    int64              `json:"com.beeper.hs.suborder,omitempty"`
	BeeperHSOrderString BeeperEncodedOrder `json:"com.beeper.hs.order_string,omitempty"`
	BeeperFromBackup    bool               `json:"com.beeper.from_backup,omitempty"`
}

func (*Unsigned) IsEmpty added in v0.9.30

func (us *Unsigned) IsEmpty() bool

type UserReceipts added in v0.12.0

type UserReceipts map[id.UserID]ReadReceipt

func (UserReceipts) Set added in v0.12.0

func (ur UserReceipts) Set(userID id.UserID, receipt ReadReceipt)

type VerificationAcceptEventContent added in v0.7.0

type VerificationAcceptEventContent struct {
	ToDeviceVerificationEvent
	InRoomVerificationEvent

	// Commitment is the hash 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 jsonbytes.UnpaddedBytes `json:"commitment"`
	// Hash is the hash method the device is choosing to use, out of the
	// options in the m.key.verification.start message.
	Hash VerificationHashMethod `json:"hash"`
	// KeyAgreementProtocol is 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"`
	// MessageAuthenticationCode is 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"`
	// ShortAuthenticationString is a list of 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"`
}

VerificationAcceptEventContent represents the content of an m.key.verification.accept event (both the to-device and the in-room version) as described in Section 11.12.2.2.2 of the Spec.

type VerificationCancelCode added in v0.7.0

type VerificationCancelCode string
const (
	VerificationCancelCodeUser               VerificationCancelCode = "m.user"
	VerificationCancelCodeTimeout            VerificationCancelCode = "m.timeout"
	VerificationCancelCodeUnknownTransaction VerificationCancelCode = "m.unknown_transaction"
	VerificationCancelCodeUnknownMethod      VerificationCancelCode = "m.unknown_method"
	VerificationCancelCodeUnexpectedMessage  VerificationCancelCode = "m.unexpected_message"
	VerificationCancelCodeKeyMismatch        VerificationCancelCode = "m.key_mismatch"
	VerificationCancelCodeUserMismatch       VerificationCancelCode = "m.user_mismatch"
	VerificationCancelCodeInvalidMessage     VerificationCancelCode = "m.invalid_message"
	VerificationCancelCodeAccepted           VerificationCancelCode = "m.accepted"
	VerificationCancelCodeSASMismatch        VerificationCancelCode = "m.mismatched_sas"
	VerificationCancelCodeCommitmentMismatch VerificationCancelCode = "m.mismatched_commitment"

	// Non-spec codes
	VerificationCancelCodeInternalError       VerificationCancelCode = "com.beeper.internal_error"
	VerificationCancelCodeMasterKeyNotTrusted VerificationCancelCode = "com.beeper.master_key_not_trusted" // the master key is not trusted by this device, but the QR code that was scanned was from a device that doesn't trust the master key
)

type VerificationCancelEventContent added in v0.7.0

type VerificationCancelEventContent struct {
	ToDeviceVerificationEvent
	InRoomVerificationEvent

	// Code is the error code for why the process/request was cancelled by the
	// user.
	Code VerificationCancelCode `json:"code"`
	// Reason is 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"`
}

VerificationCancelEventContent represents the content of an m.key.verification.cancel event (both the to-device and the in-room version) as described in Section 11.12.2.1 of the Spec.

type VerificationDoneEventContent added in v0.18.0

type VerificationDoneEventContent struct {
	ToDeviceVerificationEvent
	InRoomVerificationEvent
}

VerificationDoneEventContent represents the content of an m.key.verification.done event (both the to-device and the in-room version) as described in Section 11.12.2.1 of the Spec.

This type is an alias for [VerificationRelatable] since there are no additional fields defined by the spec.

type VerificationHashMethod added in v0.7.0

type VerificationHashMethod string
const VerificationHashMethodSHA256 VerificationHashMethod = "sha256"

type VerificationKeyEventContent added in v0.7.0

type VerificationKeyEventContent struct {
	ToDeviceVerificationEvent
	InRoomVerificationEvent

	// Key is the device’s ephemeral public key.
	Key jsonbytes.UnpaddedBytes `json:"key"`
}

VerificationKeyEventContent represents the content of an m.key.verification.key event (both the to-device and the in-room version) as described in Section 11.12.2.2.2 of the Spec.

type VerificationMACEventContent added in v0.18.0

type VerificationMACEventContent struct {
	ToDeviceVerificationEvent
	InRoomVerificationEvent

	// Keys is the MAC of the comma-separated, sorted, list of key IDs given in
	// the MAC property.
	Keys jsonbytes.UnpaddedBytes `json:"keys"`
	// MAC is a map of the key ID to the MAC of the key, using the algorithm in
	// the verification process.
	MAC map[id.KeyID]jsonbytes.UnpaddedBytes `json:"mac"`
}

VerificationMACEventContent represents the content of an m.key.verification.mac event (both the to-device and the in-room version) as described in Section 11.12.2.2.2 of the Spec.

type VerificationMethod added in v0.7.0

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

	VerificationMethodReciprocate VerificationMethod = "m.reciprocate.v1"
	VerificationMethodQRCodeShow  VerificationMethod = "m.qr_code.show.v1"
	VerificationMethodQRCodeScan  VerificationMethod = "m.qr_code.scan.v1"
)

type VerificationReadyEventContent added in v0.8.0

type VerificationReadyEventContent struct {
	ToDeviceVerificationEvent
	InRoomVerificationEvent

	// FromDevice is the device ID which is initiating the request.
	FromDevice id.DeviceID `json:"from_device"`
	// Methods is a list of the verification methods supported by the sender.
	Methods []VerificationMethod `json:"methods"`
}

VerificationReadyEventContent represents the content of an m.key.verification.ready event (both the to-device and the in-room version) as described in Section 11.12.2.1 of the Spec.

type VerificationRequestEventContent added in v0.7.0

type VerificationRequestEventContent struct {
	ToDeviceVerificationEvent
	// FromDevice is the device ID which is initiating the request.
	FromDevice id.DeviceID `json:"from_device"`
	// Methods is a list of the verification methods supported by the sender.
	Methods []VerificationMethod `json:"methods"`
	// Timestamp is the time at which the request was made.
	Timestamp jsontime.UnixMilli `json:"timestamp,omitempty"`
}

VerificationRequestEventContent represents the content of an m.key.verification.request to-device event as described in Section 11.12.2.1 of the Spec.

For the in-room version, use a standard MessageEventContent struct.

func VerificationRequestEventContentFromMessage added in v0.18.0

func VerificationRequestEventContentFromMessage(evt *Event) *VerificationRequestEventContent

VerificationRequestEventContentFromMessage converts an in-room verification request message event to a VerificationRequestEventContent.

type VerificationStartEventContent added in v0.7.0

type VerificationStartEventContent struct {
	ToDeviceVerificationEvent
	InRoomVerificationEvent

	// FromDevice is the device ID which is initiating the request.
	FromDevice id.DeviceID `json:"from_device"`
	// Method is the verification method to use.
	Method VerificationMethod `json:"method"`
	// NextMethod is an optional method to use to verify the other user's key.
	// Applicable when the method chosen only verifies one user’s key. This
	// field will never be present if the method verifies keys both ways.
	NextMethod VerificationMethod `json:"next_method,omitempty"`

	// Hashes are the hash methods the sending device understands. This field
	// is only applicable when the method is m.sas.v1.
	Hashes []VerificationHashMethod `json:"hashes,omitempty"`
	// KeyAgreementProtocols is the list of key agreement protocols the sending
	// device understands. This field is only applicable when the method is
	// m.sas.v1.
	KeyAgreementProtocols []KeyAgreementProtocol `json:"key_agreement_protocols,omitempty"`
	// MessageAuthenticationCodes is a list of the MAC methods that the sending
	// device understands. This field is only applicable when the method is
	// m.sas.v1.
	MessageAuthenticationCodes []MACMethod `json:"message_authentication_codes"`
	// ShortAuthenticationString is a list of SAS methods the sending device
	// (and the sending device's user) understands. This field is only
	// applicable when the method is m.sas.v1.
	ShortAuthenticationString []SASMethod `json:"short_authentication_string"`

	// Secret is the shared secret from the QR code. This field is only
	// applicable when the method is m.reciprocate.v1.
	Secret jsonbytes.UnpaddedBytes `json:"secret,omitempty"`
}

VerificationStartEventContent represents the content of an m.key.verification.start event (both the to-device and the in-room version) as described in Section 11.12.2.1 of the Spec.

This struct also contains the fields for an m.key.verification.start event using the VerificationMethodSAS method as described in Section 11.12.2.2.2 and an m.key.verification.start using VerificationMethodReciprocate as described in Section 11.12.2.4.2.

type VerificationTransactionable added in v0.18.0

type VerificationTransactionable interface {
	GetTransactionID() id.VerificationTransactionID
	SetTransactionID(id.VerificationTransactionID)
}

Jump to

Keyboard shortcuts

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