matrixapi

package module
v0.0.0-...-0a02ea0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2019 License: MIT Imports: 11 Imported by: 0

README

go-matrix-api

Documentation

Overview

https://matrix.org/docs/spec/client_server/r0.4.0.html#id307

Index

Constants

View Source
const (
	VisibilityTypePrivate = "private"
	VisibilityTypePublic  = "public"
)
View Source
const (
	GuestAccessCanJoin   = "can_join"
	GuestAccessForbidden = "forbidden"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	ErrorCode    string `json:"errcode"`
	Err          string `json:"error"`
	RetryAfterMs int    `json:"retry_after_ms"`
}

APIError represents server reply in case of error https://matrix.org/docs/spec/client_server/r0.4.0.html#api-standards

func (*APIError) Error

func (apiError *APIError) Error() string

Error return API error as string

type AccountData

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

type AuthenticationType

type AuthenticationType string

Authentication types https://matrix.org/docs/spec/client_server/r0.4.0.html#id198

const (
	// Password-based
	// https://matrix.org/docs/spec/client_server/r0.4.0.html#id199
	AuthenticationTypePassword AuthenticationType = "m.login.password"

	// Google ReCaptcha
	// https://matrix.org/docs/spec/client_server/r0.4.0.html#id200
	AuthenticationTypeRecaptcha AuthenticationType = "m.login.recaptcha"

	// OAuth2-based
	// https://matrix.org/docs/spec/client_server/r0.4.0.html#id202
	AuthenticationTypeOauth2 AuthenticationType = "m.login.oauth2"

	// Email-based (identity server)
	// https://matrix.org/docs/spec/client_server/r0.4.0.html#id203
	AuthenticationTypeEmail AuthenticationType = "m.login.email.identity"

	// Token-based
	// https://matrix.org/docs/spec/client_server/r0.4.0.html#id201
	AuthenticationTypeToken AuthenticationType = "m.login.token"

	// Dummy Auth
	// https://matrix.org/docs/spec/client_server/r0.4.0.html#id204
	AuthenticationTypeDummy AuthenticationType = "m.login.dummy"
)

type Client

type Client struct {
	AccessToken string
	HomeServer  string
	UserID      string

	Invites map[string]*InviteC

	InviteHandler  InviteHandler
	MessageHandler MessageHandler

	HTTPClient *http.Client

	Logger io.Writer
	// contains filtered or unexported fields
}

func NewClientWithPassword

func NewClientWithPassword(host string, user, password string) (*Client, error)

func (*Client) CreateRoom

func (client *Client) CreateRoom(createRoomRequest CreateRoomRequest) (roomID string, err error)

func (*Client) JoinRoom

func (client *Client) JoinRoom(roomID string) error

func (*Client) JoinedRooms

func (client *Client) JoinedRooms(fromCache bool) (map[string]*JoinedRoomC, error)

JoinedRooms returns a list of the user's current rooms. If fromCache is true then local cache will be used. https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-joined-rooms

func (*Client) LeaveRoom

func (client *Client) LeaveRoom(room string) error

func (*Client) Logout

func (client *Client) Logout() error

func (*Client) SendTextMessage

func (client *Client) SendTextMessage(roomID string, text string) (eventID string, err error)

TODO: make universal {roomId}/send/{eventType}/{txnId} https://matrix.org/docs/spec/client_server/r0.4.0.html#id258

func (*Client) SendTextReply

func (client *Client) SendTextReply(roomID string, messageID string, text string) (eventID string, err error)

TODO: make universal {roomId}/send/{eventType}/{txnId} https://matrix.org/docs/spec/client_server/r0.4.0.html#id258

func (*Client) Sync

func (client *Client) Sync() error

func (*Client) Versions

func (client *Client) Versions() ([]string, error)

Versions returns versions of the specification supported by the server https://matrix.org/docs/spec/client_server/r0.4.0.html#get-well-known-matrix-client

func (*Client) WhoAmI

func (client *Client) WhoAmI() (userID string, err error)

TODO: return cached client.UserID? https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-account-whoami

type CreateRoomReply

type CreateRoomReply struct {
	RoomID string `json:"room_id"` // Information about the newly created room.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-createroom

type CreateRoomRequest

type CreateRoomRequest struct {
	Visibility    VisibilityType `json:"visibility,omitempty"`
	RoomAliasName string         `json:"room_alias_name,omitempty"`
	Name          string         `json:"name,omitempty"`
	Topic         string         `json:"topic,omitempty"`
	Invite        []string       `json:"invite,omitempty"`
	Invite3pids   []Invite3pid   `json:"invite_3pid,omitempty"`
	RoomVersion   string         `json:"room_version,omitempty"`
	// TODO: проверить тип
	// CreationContent CreationContentType `json:"creation_content,omitempty"`
	InitialState []StateEvent `json:"initial_state,omitempty"`
	Preset       string       `json:"preset,omitempty"` // TODO: проверить тип
	IsDirect     bool         `json:"is_direct,omitempty"`
}

CreateRoomRequest represents room creation request https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-createroom

type DeviceLists

type DeviceLists struct {
	Changed []string `json:"changed"` // List of users who have updated their device identity keys, or who now share an encrypted room with the client since the previous sync response.
	Left    []string `json:"left"`    // List of users with whom we do not share any encrypted rooms anymore since the previous sync response.
}

type Ephemeral

type Ephemeral struct {
	Events []Event `json:"events"` // List of events.
}

type ErrorCode

type ErrorCode string

ErrorCode represents Matrix error code

const (
	MForbidden               ErrorCode = "M_FORBIDDEN"                 // Forbidden access, e.g. joining a room without permission, failed login.
	MUnknownToken            ErrorCode = "M_UNKNOWN_TOKEN"             // The access token specified was not recognised.
	MMissingToken            ErrorCode = "M_MISSING_TOKEN"             // No access token was specified for the request.
	MBadJson                 ErrorCode = "M_BAD_JSON"                  // Request contained valid JSON, but it was malformed in some way, e.g. missing required keys, invalid values for keys.
	MNotJson                 ErrorCode = "M_NOT_JSON"                  // Request did not contain valid JSON.
	MNotFound                ErrorCode = "M_NOT_FOUND"                 // No resource was found for this request.
	MLimitExceeded           ErrorCode = "M_LIMIT_EXCEEDED"            // Too many requests have been sent in a short period of time. Wait a while then try again.
	MUnknown                 ErrorCode = "M_UNKNOWN"                   // An unknown error has occurred.
	MUnrecognized            ErrorCode = "M_UNRECOGNIZED"              // The server did not understand the request.
	MUnauthorized            ErrorCode = "M_UNAUTHORIZED"              // The request was not correctly authorized. Usually due to login failures.
	MUserInUse               ErrorCode = "M_USER_IN_USE"               // Encountered when trying to register a user ID which has been taken.
	MInvalidUsername         ErrorCode = "M_INVALID_USERNAME"          // Encountered when trying to register a user ID which is not valid.
	MRoomInUse               ErrorCode = "M_ROOM_IN_USE"               // Sent when the room alias given to the createRoom API is already in use.
	MInvalidRoomState        ErrorCode = "M_INVALID_ROOM_STATE"        // Sent when the intial state given to the createRoom API is invalid.
	MThreepidInUse           ErrorCode = "M_THREEPID_IN_USE"           // Sent when a threepid given to an API cannot be used because the same threepid is already in use.
	MThreepidNotFound        ErrorCode = "M_THREEPID_NOT_FOUND"        // Sent when a threepid given to an API cannot be used because no record matching the threepid was found.
	MThreepidAuth_failed     ErrorCode = "M_THREEPID_AUTH_FAILED"      // Authentication could not be performed on the third party identifier.
	MThreepidDenied          ErrorCode = "M_THREEPID_DENIED"           // The server does not permit this third party identifier. This may happen if the server only permits, for example, email addresses from a particular domain.
	MServerNotTrusted        ErrorCode = "M_SERVER_NOT_TRUSTED"        // The client's request used a third party server, eg. identity server, that this server does not trust.
	MUnsupportedRoomVersion  ErrorCode = "M_UNSUPPORTED_ROOM_VERSION"  // The client's request to create a room used a room version that the server does not support.
	MIncompatibleRoomVersion ErrorCode = "M_INCOMPATIBLE_ROOM_VERSION" // The client attempted to join a room that has a version the server does not support. Inspect the room_version property of the error response for the room's version.
	MBadState                ErrorCode = "M_BAD_STATE"                 // The state change requested cannot be performed, such as attempting to unban a user who is not banned.
	MGuestAccessForbidden    ErrorCode = "M_GUEST_ACCESS_FORBIDDEN"    // The room or resource does not permit guests to access it.
	MCaptchaNeeded           ErrorCode = "M_CAPTCHA_NEEDED"            // A Captcha is required to complete the request.
	MCaptchaInvalid          ErrorCode = "M_CAPTCHA_INVALID"           // The Captcha provided did not match what was expected.
	MMissingParam            ErrorCode = "M_MISSING_PARAM"             // A required parameter was missing from the request.
	MInvalidParam            ErrorCode = "M_INVALID_PARAM"             // A parameter that was specified has the wrong value. For example, the server expected an integer and instead received a string.
	MTooLarge                ErrorCode = "M_TOO_LARGE"                 // The request or entity was too large.
	MExclusive               ErrorCode = "M_EXCLUSIVE"                 // The resource being requested is reserved by an application service, or the application service making the request has not created the resource.
)

type Event

type Event struct {
	Type string `json:"type"` // Required. The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'
	// contains filtered or unexported fields
}

type EventContent

type EventContent struct {
	AvatarURL string `json:"avatar_url"` // The avatar URL for this user, if any. This is added by the homeserver.
	// TODO: string or null
	DisplayName      string       `json:"displayname"`        // The display name for this user, if any. This is added by the homeserver.
	Membership       Membership   `json:"membership"`         // Required. The membership state of the user. One of: ["invite", "join", "knock", "leave", "ban"]
	IsDirect         bool         `json:"is_direct"`          // Flag indicating if the room containing this event was created with the intention of being a direct chat. See Direct Messaging.
	ThirdPartyInvite Invite       `json:"third_party_invite"` //
	Unsigned         UnsignedData `json:"unsigned"`           // Contains optional extra information about the event.
}

type Flow

type Flow struct {
	Type AuthenticationType `json:"type"`
}

type GetLoginReply

type GetLoginReply struct {
	Flows []Flow // The homeserver's supported login types
}

type GuestAccess

type GuestAccess string

type IncomingMessage

type IncomingMessage struct {
	RoomID   string
	SenderID string
	Type     MessageType
	Body     string
	Time     time.Time
	EventID  string
}

type Invite

type Invite struct {
	DisplayName string `json:"display_name"` // Required. A name which can be displayed to represent the user instead of their third party identifier
	Signed      signed `json:"signed"`       // Required. A block of content which has been signed, which servers can use to verify the event. Clients should ignore this.
}

type Invite3pid

type Invite3pid struct {
	IDServer string `json:"id_server"` // Required. The hostname+port of the identity server which should be used for third party identifier lookups.
	Medium   string `json:"medium"`    // Required. The kind of address being passed in the address field, for example email.
	Address  string `json:"address"`   // Required. The invitee's third party identifier.
}

Invite3pid represents third party IDs to invite into the room https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-createroom

type InviteC

type InviteC struct {
	JoinRules JoinRule
	InviterID string
	Members   map[string]*RoomMember
}

type InviteHandler

type InviteHandler func(roomID, inviterID string)

type InviteState

type InviteState struct {
	Events []StrippedState `json:"events"` // The StrippedState events that form the invite state.
}

type InvitedRoom

type InvitedRoom struct {
	InviteState InviteState `json:"invite_state"` // The state of a room that the user has been invited to. These state events may only have the sender, type, state_key and content keys present. These events do not replace any state that the client already has for the room, for example if the client has archived the room. Instead the client should keep two separate copies of the state: the one from the invite_state and one from the archived state. If the client joins the room then the current state will be given as a delta against the archived state not the invite_state.
}

type JoinRoomReply

type JoinRoomReply struct {
	RoomID string `json:"room_id"` // The joined room ID must be returned in the room_id field.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id276

type JoinRule

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

type JoinedRoom

type JoinedRoom struct {
	State               State                    `json:"state"`                // Updates to the state, between the time indicated by the since parameter, and the start of the timeline (or all state up to the start of the timeline, if since is not given, or full_state is true).
	Timeline            Timeline                 `json:"timeline"`             // The timeline of messages and state changes in the room.
	Ephemeral           Ephemeral                `json:"ephemeral"`            // The ephemeral events in the room that aren't recorded in the timeline or state of the room. e.g. typing.
	AccountData         AccountData              `json:"account_data"`         // The private data that this user has attached to this room.
	UnreadNotifications UnreadNotificationCounts `json:"unread_notifications"` // Counts of unread notifications for this room
}

type JoinedRoomC

type JoinedRoomC struct {
	Name              string
	Version           string
	Creator           string
	JoinRules         JoinRule
	HistoryVisibility string
	Federate          bool
	Members           map[string]*RoomMember
	PowerLevels       MRoomPowerLevels
	GuestAccess       GuestAccess
	Topic             string
}

type JoinedRoomReply

type JoinedRoomReply struct {
	JoinedRooms []string `json:"joined_rooms"`
}

type LeftRoom

type LeftRoom struct {
	State       State       `json:"state"`        // The state updates for the room up to the start of the timeline.
	Timeline    Timeline    `json:"timeline"`     // The timeline of messages and state changes in the room up to the point when the user left.
	AccountData AccountData `json:"account_data"` // The private data that this user has attached to this room.
}

type LoginReply

type LoginReply struct {
	AccessToken string `json:"access_token"`
	HomeServer  string `json:"home_server"`
	UserID      string `json:"user_id"`
}

type LoginRequest

type LoginRequest struct {
	Type                     AuthenticationType `json:"type"`                                  // Required. The login type being used. One of: ["m.login.password", "m.login.token"]
	Identifier               UserIdentifier     `json:"identifier"`                            // Identification information for the user.
	Password                 string             `json:"password,omitempty"`                    // Required when type is m.login.password. The user's password.
	Token                    string             `json:"token,omitempty"`                       // Required when type is m.login.token. Part of Token-based login.
	DeviceID                 string             `json:"device_id,omitempty"`                   // ID of the client device. If this does not correspond to a known client device, a new device will be created. The server will auto-generate a device_id if this is not specified.
	InitialDeviceDisplayName string             `json:"initial_device_display_name,omitempty"` // A display name to assign to the newly-created device. Ignored if device_id corresponds to a known device.
}

LoginRequest represents login request https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-login

type MInReplyTo

type MInReplyTo struct {
	EventID string `json:"event_id"`
}

type MRelatesTo

type MRelatesTo struct {
	InReplyTo MInReplyTo `json:"m.in_reply_to"`
}

type MRoomAliases

type MRoomAliases struct {
	// TODO: не уверен насчёт правильности
	Aliases []string `json:"aliases"` // Required. A list of room aliases.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id308

type MRoomCanonicalAlias

type MRoomCanonicalAlias struct {
	// TODO: не уверен насчёт правильности
	Alias string `json:"aliases"` // Required. The canonical alias.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id309

type MRoomCreate

type MRoomCreate struct {
	Creator  string `json:"creator"`      // Required. The user_id of the room creator. This is set by the homeserver.
	Federate bool   `json:"m.federate"`   // Whether users on other servers can join this room. Defaults to true if key does not exist.
	Version  string `json:"room_version"` // The version of the room. Defaults to "1" if the key does not exist.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id310

type MRoomGuestAccess

type MRoomGuestAccess struct {
	GuestAccess GuestAccess `json:"guest_access"` // Required. Whether guests can join the room. One of: ["can_join", "forbidden"]
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id519

type MRoomJoinRules

type MRoomJoinRules struct {
	JoinRule JoinRule `json:"join_rule"` // Required. The type of rules used for users wishing to join this room. One of: ["public", "knock", "invite", "private"]
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id311

type MRoomMember

type MRoomMember struct {
	// TODO: уточнить структуру
	Membership  Membership `json:"membership"`
	DisplayName string     `json:"displayname"`
	AvatarURL   string     `json:"avatar_url"`
	IsDirect    bool       `json:"is_direct"`
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id312

type MRoomMessage

type MRoomMessage struct {
	Body        string      `json:"body"`    // Required. The textual representation of this message.
	MessageType MessageType `json:"msgtype"` // Required. The type of message, e.g. m.image, m.text
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id328

type MRoomName

type MRoomName struct {
	Name string `json:"name"` //Required. The name of the room. This MUST NOT exceed 255 bytes.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id330

type MRoomPowerLevels

type MRoomPowerLevels struct {
	Ban           int            `json:"ban"`            // The level required to ban a user. Defaults to 50 if unspecified.
	Events        map[string]int `json:"events"`         // The level required to send specific event types. This is a mapping from event type to power level required.
	EventsDefault int            `json:"events_default"` // The default level required to send message events. Can be overridden by the events key. Defaults to 0 if unspecified.
	Invite        int            `json:"invite"`         // The level required to invite a user. Defaults to 50 if unspecified.
	Kick          int            `json:"kick"`           // The level required to kick a user. Defaults to 50 if unspecified.
	Redact        int            `json:"redact"`         // The level required to redact an event. Defaults to 50 if unspecified.
	StateDefault  int            `json:"state_default"`  // The default level required to send state events. Can be overridden by the events key. Defaults to 50 if unspecified, but 0 if there is no m.room.power_levels event at all.
	Users         map[string]int `json:"users"`          // The power levels for specific users. This is a mapping from user_id to power level for that user.
	UsersDefault  int            `json:"users_default"`  // The default power level for every user in the room, unless their user_id is mentioned in the users key. Defaults to 0 if unspecified.
	Notifications Notifications  `json:"notifications"`  // The power level requirements for specific notification types. This is a mapping from key to power level for that notifications key.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#m-room-power-levels

type MRoomTopic

type MRoomTopic struct {
	Topic string `json:"topic"` // Required. The topic text.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id331

type MemberEvent

type MemberEvent struct {
	Content        EventContent `json:"content"`          // Required.
	Type           string       `json:"type"`             //Required. Must be 'm.room.member'.
	EventID        string       `json:"event_id"`         // Required. The globally unique event identifier.
	Sender         string       `json:"sender"`           // Required. Contains the fully-qualified ID of the user who sent this event.
	OriginServerTs int          `json:"origin_server_ts"` // Required. Timestamp in milliseconds on originating homeserver when this event was sent.
	Unsigned       UnsignedData `json:"unsigned"`         // Contains optional extra information about the event.
	RoomID         string       `json:"room_id"`          // Required. The ID of the room associated with this event. Will not be present on events that arrive through /sync, despite being required everywhere else.
	PrevContent    EventContent `json:"prev_content"`     // Optional. The previous content for this event. If there is no previous content, this key will be missing.
	StateKey       string       `json:"state_key"`        // Required. The user_id this membership event relates to. In all cases except for when membership is join, the user ID sending the event does not need to match the user ID in the state_key, unlike other events. Regular authorisation rules still apply.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-rooms-roomid-members

type Membership

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

type MessageHandler

type MessageHandler func(IncomingMessage)

type Notifications

type Notifications struct {
	Room int `json:"room"` // The level required to trigger an @room notification. Defaults to 50 if unspecified.
}

type Presence

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

type RoomEvent

type RoomEvent struct {
	// TODO: object
	Content        json.RawMessage `json:"content"`          // Required. The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body.
	Type           string          `json:"type"`             // Required. The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'
	EventID        string          `json:"event_id"`         // Required. The globally unique event identifier.
	Sender         string          `json:"sender"`           // Required. Contains the fully-qualified ID of the user who sent this event.
	OriginServerTs int64           `json:"origin_server_ts"` // Required. Timestamp in milliseconds on originating homeserver when this event was sent.
	Unsigned       UnsignedData    `json:"unsigned"`         // Contains optional extra information about the event.
}

type RoomMember

type RoomMember struct {
	UserID      string
	Membership  Membership
	DisplayName string
	AvatarURL   string
	IsDirect    bool
}

type RoomsSyncReply

type RoomsSyncReply struct {
	Join   map[string]JoinedRoom  `json:"join"`   // The rooms that the user has joined.
	Invite map[string]InvitedRoom `json:"invite"` // The rooms that the user has been invited to.
	Leave  map[string]LeftRoom    `json:"leave"`  // The rooms that the user has left or been banned from.
}

type SendMessageReply

type SendMessageReply struct {
	EventID string `json:"event_id"` // A unique identifier for the event.
}

SendMessageReply represents reply for send message command https://matrix.org/docs/spec/client_server/r0.4.0.html#put-matrix-client-r0-rooms-roomid-state-eventtype-statekey

type SendMessageRequest

type SendMessageRequest struct {
	Body        string      `json:"body"`    // Required. The textual representation of this message.
	MessageType MessageType `json:"msgtype"` // Required. The type of message, e.g. m.image, m.text
	RelatesTo   MRelatesTo  `json:"m.relates_to,omitempty"`
}

type SetPresence

type SetPresence string
const (
	SetPresenceOffline     SetPresence = "offline"
	SetPresenceOnline      SetPresence = "online"
	SetPresenceUnavailable SetPresence = "unavailable"
)

type State

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

type StateEvent

type StateEvent struct {
	// TODO: object?
	Content        json.RawMessage `json:"content"`          // Required. The fields in this object will vary depending on the type of event. When interacting with the REST API, this is the HTTP body.
	Type           string          `json:"type"`             // Required. The type of event. This SHOULD be namespaced similar to Java package naming conventions e.g. 'com.example.subdomain.event.type'
	EventID        string          `json:"event_id"`         // Required. The globally unique event identifier.
	Sender         string          `json:"sender"`           // Required. Contains the fully-qualified ID of the user who sent this event.
	OriginServerTs int             `json:"origin_server_ts"` // Required. Timestamp in milliseconds on originating homeserver when this event was sent.
	Unsigned       UnsignedData    `json:"unsigned"`         // Contains optional extra information about the event.
	PrevContent    EventContent    `json:"prev_content"`     // Optional. The previous content for this event. If there is no previous content, this key will be missing.
	StateKey       string          `json:"state_key"`        // Required. A unique key which defines the overwriting semantics for this piece of room state. This value is often a zero-length string. The presence of this key makes this event a State Event. State keys starting with an @ are reserved for referencing user IDs, such as room members. With the exception of a few events, state events set with a given user's ID as the state key MUST only be set by that user.
}

type StrippedState

type StrippedState struct {
	// TODO: в документации EventContent, хотя вроде сервер выдаёт json.RawMessage
	Content  json.RawMessage `json:"content"`   // Required. The content for the event.
	StateKey string          `json:"state_key"` // Required. The state_key for the event.
	Type     string          `json:"type"`      // Required. The type for the event.
	Sender   string          `json:"sender"`    // Required. The sender for the event.
}

type SyncReply

type SyncReply struct {
	NextBatch              string         `json:"next_batch"`                 // Required. The batch token to supply in the since param of the next /sync request.
	Rooms                  RoomsSyncReply `json:"rooms"`                      // Updates to rooms.
	Presence               Presence       `json:"presence"`                   // The updates to the presence status of other users.
	AccountData            AccountData    `json:"account_data"`               // The global private data created by this user.
	ToDevice               ToDevice       `json:"to_device"`                  // Information on the send-to-device messages for the client device, as defined in Send-to-Device messaging.
	DeviceLists            DeviceLists    `json:"device_lists"`               // Information on end-to-end device updates, as specified in End-to-end encryption.
	DeviceOneTimeKeysCount map[string]int `json:"device_one_time_keys_count"` // Information on end-to-end encryption keys, as specified in End-to-end encryption.
}

type SyncRequest

type SyncRequest struct {
	Filter      string      `url:"filter,omitempty"`       // The ID of a filter created using the filter API or a filter JSON object encoded as a string. The server will detect whether it is an ID or a JSON object by whether the first character is a "{" open brace. Passing the JSON inline is best suited to one off requests. Creating a filter using the filter API is recommended for clients that reuse the same filter multiple times, for example in long poll requests.
	Since       string      `url:"since,omitempty"`        // A point in time to continue a sync from.
	FullState   bool        `url:"full_state,omitempty"`   // Controls whether to include the full state for all rooms the user is a member of.
	SetPresence SetPresence `url:"set_presence,omitempty"` // Controls whether the client is automatically marked as online by polling this API. If this parameter is omitted then the client is automatically marked as online when it uses this API. Otherwise if the parameter is set to "offline" then the client is not marked as being online when it uses this API. When set to "unavailable", the client is marked as being idle. One of: ["offline", "online", "unavailable"]
	Timeout     int         `url:"timeout,omitempty"`      // The maximum time to wait, in milliseconds, before returning this request. If no events (or other data) become available before this time elapses, the server will return a response with empty fields.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#id242

type Timeline

type Timeline struct {
	Events    []RoomEvent `json:"events"`     // List of events.
	Limited   bool        `json:"limited"`    // True if the number of events returned was limited by the limit on the filter.
	PrevBatch string      `json:"prev_batch"` // A token that can be supplied to the from parameter of the rooms/{roomId}/messages endpoint.
}

type ToDevice

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

TODO: проверить правильность выбора типа

type UnreadNotificationCounts

type UnreadNotificationCounts struct {
	HighlightCount    int `json:"highlight_count"`    // The number of unread notifications for this room with the highlight flag set
	NotificationCount int `json:"notification_count"` // The total number of unread notifications for this room
}

type UnsignedData

type UnsignedData struct {
	Age             int    `json:"age"`              // The time in milliseconds that has elapsed since the event was sent. This field is generated by the local homeserver, and may be incorrect if the local time on at least one of the two servers is out of sync, which can cause the age to either be negative or greater than it actually is.
	RedactedBecause Event  `json:"redacted_because"` // Optional. The event that redacted this event, if any.
	TransactionID   string `json:"transaction_id"`   // The client-supplied transaction ID, if the client being given the event is the same one which sent it.
}

type UserIdentifier

type UserIdentifier struct {
	Type    IdentifierType `json:"type"`              // Required. The type of identification. See Identifier types for supported values and additional property descriptions.
	User    string         `json:"user,omitempty"`    // The fully qualified user ID or just local part of the user ID, to log in.
	Medium  string         `json:"medium,omitempty"`  // When logging in using a third party identifier, the medium of the identifier. Must be 'email'.
	Address string         `json:"address,omitempty"` // Third party identifier for the user.
	Country string         `json:"country,omitempty"`
	Phone   string         `json:"phone,omitempty"`
}

UserIdentifier represents user identifier object https://matrix.org/docs/spec/client_server/r0.4.0.html#post-matrix-client-r0-login

type VersionsReply

type VersionsReply struct {
	Versions []string `json:"versions"` // The supported versions.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-versions

type VisibilityType

type VisibilityType string

type WhoAmIReply

type WhoAmIReply struct {
	UserID string `json:"user_id"` // Required. The user id that owns the access token.
}

https://matrix.org/docs/spec/client_server/r0.4.0.html#get-matrix-client-r0-account-whoami

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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