fclient

package
v0.0.0-...-c2391f7 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 26 Imported by: 36

Documentation

Index

Constants

View Source
const WellKnownMaxSize = 50 * 1024 // 50KB

Variables

This section is empty.

Functions

func ParseAuthorization

func ParseAuthorization(header string) (scheme string, origin, destination spec.ServerName, key gomatrixserverlib.KeyID, sig string)

Types

type Client

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

A Client makes HTTP requests to remote servers. It is used to centralise a number of configurable options, such as DNS caching, timeouts etc.

func NewClient

func NewClient(options ...ClientOption) *Client

NewClient makes a new Client. You can supply zero or more ClientOptions which control the transport, timeout, TLS validation etc - see WithTransport, WithTimeout, WithSkipVerify, WithDNSCache etc.

func (*Client) CreateMediaDownloadRequest

func (fc *Client) CreateMediaDownloadRequest(
	ctx context.Context, matrixServer spec.ServerName, mediaID string,
) (*http.Response, error)

CreateMediaDownloadRequest creates a request for media on a homeserver and returns the http.Response or an error

func (*Client) DoHTTPRequest

func (fc *Client) DoHTTPRequest(ctx context.Context, req *http.Request) (*http.Response, error)

DoHTTPRequest creates an outgoing request ID and adds it to the context before sending off the request and awaiting a response.

If the returned error is nil, the Response will contain a non-nil Body which the caller is expected to close.

func (*Client) DoRequestAndParseResponse

func (fc *Client) DoRequestAndParseResponse(
	ctx context.Context,
	req *http.Request,
	result interface{},
) error

DoRequestAndParseResponse calls DoHTTPRequest and then decodes the response.

If the HTTP response is not a 200, an attempt is made to parse the response body into a gomatrix.RespError. In any case, a non-200 response will result in a gomatrix.HTTPError.

func (*Client) GetServerKeys

func (fc *Client) GetServerKeys(
	ctx context.Context, matrixServer spec.ServerName,
) (gomatrixserverlib.ServerKeys, error)

GetServerKeys asks a matrix server for its signing keys and TLS cert

func (*Client) GetVersion

func (fc *Client) GetVersion(
	ctx context.Context, s spec.ServerName,
) (res Version, err error)

GetVersion gets the version information of a homeserver. See https://matrix.org/docs/spec/server_server/r0.1.1.html#get-matrix-federation-v1-version

func (*Client) LookupServerKeys

func (fc *Client) LookupServerKeys(
	ctx context.Context, matrixServer spec.ServerName,
	keyRequests map[gomatrixserverlib.PublicKeyLookupRequest]spec.Timestamp,
) ([]gomatrixserverlib.ServerKeys, error)

LookupServerKeys looks up the keys for a matrix server from a matrix server. The first argument is the name of the matrix server to download the keys from. The second argument is a map from (server name, key ID) pairs to timestamps. The (server name, key ID) pair identifies the key to download. The timestamps tell the server when the keys need to be valid until. Perspective servers can use that timestamp to determine whether they can return a cached copy of the keys or whether they will need to retrieve a fresh copy of the keys. Returns the keys returned by the server, or an error if there was a problem talking to the server.

func (*Client) LookupUserInfo

func (fc *Client) LookupUserInfo(
	ctx context.Context, matrixServer spec.ServerName, token string,
) (u UserInfo, err error)

LookupUserInfo gets information about a user from a given matrix homeserver using a bearer access token.

func (*Client) SetUserAgent

func (fc *Client) SetUserAgent(ua string)

SetUserAgent sets the user agent string that is sent in the headers of outbound HTTP requests.

type ClientOption

type ClientOption func(*clientOptions)

ClientOption are supplied to NewClient or NewFederationClient.

func WithDNSCache

func WithDNSCache(cache *DNSCache) ClientOption

WithDNSCache is an option that can be supplied to either NewClient or NewFederationClient. This option will be ineffective if WithTransport has already been supplied.

func WithKeepAlives

func WithKeepAlives(keepAlives bool) ClientOption

WithKeepAlives is an option that can be supplied to either NewClient or NewFederationClient. This option will be ineffective if WithTransport has already been supplied.

func WithSkipVerify

func WithSkipVerify(skipVerify bool) ClientOption

WithSkipVerify is an option that can be supplied to either NewClient or NewFederationClient. This option will be ineffective if WithTransport has already been supplied.

func WithTimeout

func WithTimeout(duration time.Duration) ClientOption

WithTimeout is an option that can be supplied to either NewClient or NewFederationClient.

func WithTransport

func WithTransport(transport http.RoundTripper) ClientOption

WithTransport is an option that can be supplied to either NewClient or NewFederationClient. Supplying this option will render WithDNSCache and WithSkipVerify ineffective.

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent enables specifying the user agent for the http client.

func WithWellKnownSRVLookups

func WithWellKnownSRVLookups(wellKnownSRV bool) ClientOption

WithWellKnownSRVLookups enables federation lookups of well-known and SRV records.

type CrossSigningBody

type CrossSigningBody interface {
	// contains filtered or unexported methods
}

type CrossSigningForKeyOrDevice

type CrossSigningForKeyOrDevice struct {
	CrossSigningBody
}

func (CrossSigningForKeyOrDevice) MarshalJSON

func (c CrossSigningForKeyOrDevice) MarshalJSON() ([]byte, error)

Implements json.Marshaler

func (*CrossSigningForKeyOrDevice) UnmarshalJSON

func (c *CrossSigningForKeyOrDevice) UnmarshalJSON(b []byte) error

Implements json.Unmarshaler

type CrossSigningKey

type CrossSigningKey struct {
	Signatures map[string]map[gomatrixserverlib.KeyID]spec.Base64Bytes `json:"signatures,omitempty"`
	Keys       map[gomatrixserverlib.KeyID]spec.Base64Bytes            `json:"keys"`
	Usage      []CrossSigningKeyPurpose                                `json:"usage"`
	UserID     string                                                  `json:"user_id"`
}

https://spec.matrix.org/unstable/client-server-api/#post_matrixclientr0keysdevice_signingupload

type CrossSigningKeyPurpose

type CrossSigningKeyPurpose string
const (
	CrossSigningKeyPurposeMaster      CrossSigningKeyPurpose = "master"
	CrossSigningKeyPurposeSelfSigning CrossSigningKeyPurpose = "self_signing"
	CrossSigningKeyPurposeUserSigning CrossSigningKeyPurpose = "user_signing"
)

type CrossSigningKeys

type CrossSigningKeys struct {
	MasterKey      CrossSigningKey `json:"master_key"`
	SelfSigningKey CrossSigningKey `json:"self_signing_key"`
	UserSigningKey CrossSigningKey `json:"user_signing_key"`
}

type DNSCache

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

func NewDNSCache

func NewDNSCache(size int, duration time.Duration) *DNSCache

func (*DNSCache) DialContext

func (c *DNSCache) DialContext(ctx context.Context, network, address string) (net.Conn, error)

type DeviceKeys

type DeviceKeys struct {
	RespUserDeviceKeys
	// Additional data added to the device key information by intermediate servers, and not covered by the signatures.
	// E.g { "device_display_name": "Alice's mobile phone" }
	Unsigned map[string]interface{} `json:"unsigned"`
}

DeviceKeys as per https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-query

func (*DeviceKeys) Scan

func (s *DeviceKeys) Scan(src interface{}) error

func (DeviceKeys) Value

func (s DeviceKeys) Value() (driver.Value, error)

type EmptyResp

type EmptyResp struct {
}

type FederationClient

type FederationClient interface {
	gomatrixserverlib.KeyClient

	DoRequestAndParseResponse(ctx context.Context, req *http.Request, result interface{}) error

	SendTransaction(ctx context.Context, t gomatrixserverlib.Transaction) (res RespSend, err error)

	// Perform operations
	LookupRoomAlias(ctx context.Context, origin, s spec.ServerName, roomAlias string) (res RespDirectory, err error)
	Peek(ctx context.Context, origin, s spec.ServerName, roomID, peekID string, roomVersions []gomatrixserverlib.RoomVersion) (res RespPeek, err error)
	MakeJoin(ctx context.Context, origin, s spec.ServerName, roomID, userID string) (res RespMakeJoin, err error)
	SendJoin(ctx context.Context, origin, s spec.ServerName, event gomatrixserverlib.PDU) (res RespSendJoin, err error)
	SendJoinPartialState(ctx context.Context, origin, s spec.ServerName, event gomatrixserverlib.PDU) (res RespSendJoin, err error)
	MakeLeave(ctx context.Context, origin, s spec.ServerName, roomID, userID string) (res RespMakeLeave, err error)
	SendLeave(ctx context.Context, origin, s spec.ServerName, event gomatrixserverlib.PDU) (err error)
	SendInviteV2(ctx context.Context, origin, s spec.ServerName, request InviteV2Request) (res RespInviteV2, err error)
	SendInviteV3(ctx context.Context, origin, s spec.ServerName, request InviteV3Request, userID spec.UserID) (res RespInviteV2, err error)
	MakeKnock(ctx context.Context, origin, s spec.ServerName, roomID, userID string, roomVersions []gomatrixserverlib.RoomVersion) (res RespMakeKnock, err error)
	SendKnock(ctx context.Context, origin, s spec.ServerName, event gomatrixserverlib.PDU) (res RespSendKnock, err error)

	GetEvent(ctx context.Context, origin, s spec.ServerName, eventID string) (res gomatrixserverlib.Transaction, err error)

	GetEventAuth(ctx context.Context, origin, s spec.ServerName, roomVersion gomatrixserverlib.RoomVersion, roomID, eventID string) (res RespEventAuth, err error)
	GetUserDevices(ctx context.Context, origin, s spec.ServerName, userID string) (RespUserDevices, error)
	ClaimKeys(ctx context.Context, origin, s spec.ServerName, oneTimeKeys map[string]map[string]string) (RespClaimKeys, error)
	QueryKeys(ctx context.Context, origin, s spec.ServerName, keys map[string][]string) (RespQueryKeys, error)
	Backfill(ctx context.Context, origin, s spec.ServerName, roomID string, limit int, eventIDs []string) (res gomatrixserverlib.Transaction, err error)
	MSC2836EventRelationships(ctx context.Context, origin, dst spec.ServerName, r MSC2836EventRelationshipsRequest, roomVersion gomatrixserverlib.RoomVersion) (res MSC2836EventRelationshipsResponse, err error)
	RoomHierarchy(ctx context.Context, origin, dst spec.ServerName, roomID string, suggestedOnly bool) (res RoomHierarchyResponse, err error)

	ExchangeThirdPartyInvite(ctx context.Context, origin, s spec.ServerName, builder gomatrixserverlib.ProtoEvent) (err error)
	LookupState(ctx context.Context, origin, s spec.ServerName, roomID string, eventID string, roomVersion gomatrixserverlib.RoomVersion) (res RespState, err error)
	LookupStateIDs(ctx context.Context, origin, s spec.ServerName, roomID string, eventID string) (res RespStateIDs, err error)
	LookupMissingEvents(ctx context.Context, origin, s spec.ServerName, roomID string, missing MissingEvents, roomVersion gomatrixserverlib.RoomVersion) (res RespMissingEvents, err error)

	GetPublicRooms(
		ctx context.Context, origin, s spec.ServerName, limit int, since string,
		includeAllNetworks bool, thirdPartyInstanceID string,
	) (res RespPublicRooms, err error)
	GetPublicRoomsFiltered(
		ctx context.Context, origin, s spec.ServerName, limit int, since, filter string,
		includeAllNetworks bool, thirdPartyInstanceID string,
	) (res RespPublicRooms, err error)

	LookupProfile(
		ctx context.Context, origin, s spec.ServerName, userID string, field string,
	) (res RespProfile, err error)

	P2PSendTransactionToRelay(ctx context.Context, u spec.UserID, t gomatrixserverlib.Transaction, forwardingServer spec.ServerName) (res EmptyResp, err error)
	P2PGetTransactionFromRelay(ctx context.Context, u spec.UserID, prev RelayEntry, relayServer spec.ServerName) (res RespGetRelayTransaction, err error)
}

an interface for gmsl.FederationClient - contains functions called by federationapi only.

func NewFederationClient

func NewFederationClient(
	identities []*SigningIdentity,
	options ...ClientOption,
) FederationClient

NewFederationClient makes a new FederationClient. You can supply zero or more ClientOptions which control the transport, timeout, TLS validation etc - see WithTransport, WithTimeout, WithSkipVerify, WithDNSCache etc.

type FederationRequest

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

A FederationRequest is a request to send to a remote server or a request received from a remote server. Federation requests are signed by building a JSON object and signing it

func NewFederationRequest

func NewFederationRequest(method string, origin, destination spec.ServerName, requestURI string) FederationRequest

NewFederationRequest creates a matrix request. Takes an HTTP method, a destination homeserver and a request path which can have a query string. The destination is the name of a matrix homeserver. The request path must begin with a slash. Eg. NewFederationRequest("GET", "matrix.org", "/_matrix/federation/v1/send/123")

func VerifyHTTPRequest

func VerifyHTTPRequest(
	req *http.Request, now time.Time,
	destination spec.ServerName,
	isLocalServerName func(spec.ServerName) bool,
	keys gomatrixserverlib.JSONVerifier,
) (*FederationRequest, util.JSONResponse)

VerifyHTTPRequest extracts and verifies the contents of a net/http.Request. It consumes the body of the request. The JSON content can be accessed using FederationRequest.Content() Returns an 400 error if there was a problem parsing the request. It authenticates the request using an ed25519 signature using the JSONVerifier. The origin server can be accessed using FederationRequest.Origin() Returns a 401 error if there was a problem authenticating the request. HTTP handlers using this should be careful that they only use the parts of the request that have been authenticated: the method, the request path, the query parameters, and the JSON content. In particular the version of HTTP and the headers aren't protected by the signature.

func (*FederationRequest) Content

func (r *FederationRequest) Content() []byte

Content returns the JSON content for the request.

func (*FederationRequest) Destination

func (r *FederationRequest) Destination() spec.ServerName

Destination returns the server that the request was targeted to.

func (*FederationRequest) HTTPRequest

func (r *FederationRequest) HTTPRequest() (*http.Request, error)

HTTPRequest constructs an net/http.Request for this matrix request. The request can be passed to net/http.Client.Do().

func (*FederationRequest) Method

func (r *FederationRequest) Method() string

Method returns the JSON method for the request.

func (*FederationRequest) Origin

func (r *FederationRequest) Origin() spec.ServerName

Origin returns the server that the request originated on.

func (*FederationRequest) RequestURI

func (r *FederationRequest) RequestURI() string

RequestURI returns the path and query sections of the HTTP request URL.

func (*FederationRequest) SetContent

func (r *FederationRequest) SetContent(content interface{}) error

SetContent sets the JSON content for the request. Returns an error if there already is JSON content present on the request.

func (*FederationRequest) Sign

func (r *FederationRequest) Sign(serverName spec.ServerName, keyID gomatrixserverlib.KeyID, privateKey ed25519.PrivateKey) error

Sign the matrix request with an ed25519 key. Uses the algorithm specified https://matrix.org/docs/spec/server_server/unstable.html#request-authentication Updates the request with the signature in place. Returns an error if there was a problem signing the request.

type InviteV2Request

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

InviteV2Request is used in the body of a /_matrix/federation/v2/invite request.

func NewInviteV2Request

func NewInviteV2Request(event gomatrixserverlib.PDU, state []gomatrixserverlib.InviteStrippedState) (
	request InviteV2Request, err error,
)

func (*InviteV2Request) Event

Event returns the invite event.

func (*InviteV2Request) InviteRoomState

func (i *InviteV2Request) InviteRoomState() []gomatrixserverlib.InviteStrippedState

InviteRoomState returns stripped state events for the room, containing enough information for the client to identify the room.

func (InviteV2Request) MarshalJSON

func (i InviteV2Request) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

func (*InviteV2Request) RoomVersion

RoomVersion returns the room version of the invited room.

func (*InviteV2Request) UnmarshalJSON

func (i *InviteV2Request) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaller

type InviteV3Request

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

InviteV3Request is used in the body of a /_matrix/federation/v3/invite request.

func (*InviteV3Request) Event

Event returns the invite event.

func (*InviteV3Request) InviteRoomState

func (i *InviteV3Request) InviteRoomState() []gomatrixserverlib.InviteStrippedState

InviteRoomState returns stripped state events for the room, containing enough information for the client to identify the room.

func (InviteV3Request) MarshalJSON

func (i InviteV3Request) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

func (*InviteV3Request) RoomVersion

RoomVersion returns the room version of the invited room.

func (*InviteV3Request) UnmarshalJSON

func (i *InviteV3Request) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaller

type MSC2836EventRelationshipsRequest

type MSC2836EventRelationshipsRequest struct {
	EventID         string `json:"event_id"`
	MaxDepth        int    `json:"max_depth"`
	MaxBreadth      int    `json:"max_breadth"`
	Limit           int    `json:"limit"`
	DepthFirst      bool   `json:"depth_first"`
	RecentFirst     bool   `json:"recent_first"`
	IncludeParent   bool   `json:"include_parent"`
	IncludeChildren bool   `json:"include_children"`
	Direction       string `json:"direction"`
	Batch           string `json:"batch"`
	AutoJoin        bool   `json:"auto_join"`
}

MSC2836EventRelationshipsRequest is a request to /event_relationships from https://github.com/matrix-org/matrix-doc/blob/kegan/msc/threading/proposals/2836-threading.md nolint:maligned

func NewMSC2836EventRelationshipsRequest

func NewMSC2836EventRelationshipsRequest(body io.Reader) (*MSC2836EventRelationshipsRequest, error)

NewMSC2836EventRelationshipsRequest creates a new MSC2836 /event_relationships request with defaults set. https://github.com/matrix-org/matrix-doc/blob/kegan/msc/threading/proposals/2836-threading.md

func (*MSC2836EventRelationshipsRequest) Defaults

func (r *MSC2836EventRelationshipsRequest) Defaults()

Defaults sets default values.

type MSC2836EventRelationshipsResponse

type MSC2836EventRelationshipsResponse struct {
	Events    gomatrixserverlib.EventJSONs `json:"events"`
	NextBatch string                       `json:"next_batch"`
	Limited   bool                         `json:"limited"`
	AuthChain gomatrixserverlib.EventJSONs `json:"auth_chain"`
}

MSC2836EventRelationshipsResponse is a response to /event_relationships from https://github.com/matrix-org/matrix-doc/blob/kegan/msc/threading/proposals/2836-threading.md

type MissingEvents

type MissingEvents struct {
	// The maximum number of events to retrieve.
	Limit int `json:"limit"`
	// The minimum depth of events to retrieve.
	MinDepth int `json:"min_depth"`
	// The latest event IDs that the sender already has.
	EarliestEvents []string `json:"earliest_events"`
	// The event IDs to retrieve the previous events for.
	LatestEvents []string `json:"latest_events"`
}

MissingEvents represents a request for missing events. https://matrix.org/docs/spec/server_server/r0.1.3#post-matrix-federation-v1-get-missing-events-roomid

type PDUResult

type PDUResult struct {
	// If not empty then this is a human readable description of a problem
	// encountered processing an event.
	Error string `json:"error,omitempty"`
}

A PDUResult is the result of processing a matrix room event.

type PublicRoom

type PublicRoom struct {
	// The canonical alias of the room, if any.
	CanonicalAlias string `json:"canonical_alias,omitempty"`
	// The name of the room, if any.
	Name string `json:"name,omitempty"`
	// The number of members joined to the room.
	JoinedMembersCount int `json:"num_joined_members"`
	// The ID of the room.
	RoomID string `json:"room_id"`
	// The topic of the room, if any.
	Topic string `json:"topic,omitempty"`
	// Whether the room may be viewed by guest users without joining.
	WorldReadable bool `json:"world_readable"`
	// Whether guest users may join the room and participate in it. If they can, they will be subject to ordinary power level rules like any other user.
	GuestCanJoin bool `json:"guest_can_join"`
	// The URL for the room's avatar, if one is set.
	AvatarURL string `json:"avatar_url,omitempty"`
	// The join rule for this room
	JoinRule string `json:"join_rule,omitempty"`
}

PublicRoom stores the info of a room returned by GET /_matrix/federation/v1/publicRooms

type RelayEntry

type RelayEntry struct {
	EntryID int64 `json:"entry_id"`
}

A RelayEntry is used to track the nid of an event received from a relay server. It is used as the request body of a GET to /_matrix/federation/v1/relay_txn/{userID}

type RelayEvents

type RelayEvents struct {
	PDUs []json.RawMessage       `json:"pdus"`
	EDUs []gomatrixserverlib.EDU `json:"edus"`
}

RelayEvents is the request body of a PUT to /_matrix/federation/v1/send_relay/{txnID}/{userID}

type ResolutionResult

type ResolutionResult struct {
	Destination   string          // The hostname and port to send federation requests to.
	Host          spec.ServerName // The value of the Host headers.
	TLSServerName string          // The TLS server name to request a certificate for.
}

ResolutionResult is a result of looking up a Matrix homeserver according to the federation specification.

func ResolveServer

func ResolveServer(ctx context.Context, serverName spec.ServerName) (results []ResolutionResult, err error)

ResolveServer implements the server name resolution algorithm described at https://matrix.org/docs/spec/server_server/r0.1.1.html#resolving-server-names Returns a slice of ResolutionResult that can be used to send a federation request to the server using a given server name. Returns an error if the server name isn't valid.

type RespClaimKeys

type RespClaimKeys struct {
	// Required. One-time keys for the queried devices. A map from user ID, to a map from devices to a map
	// from <algorithm>:<key_id> to the key object or a string.
	OneTimeKeys map[string]map[string]map[string]json.RawMessage `json:"one_time_keys"`
}

RespClaimKeys is the response for https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-claim

type RespDirectory

type RespDirectory struct {
	// The matrix room ID the room alias corresponds to.
	RoomID string `json:"room_id"`
	// A list of matrix servers that the directory server thinks could be used
	// to join the room. The joining server may need to try multiple servers
	// before it finds one that it can use to join the room.
	Servers []spec.ServerName `json:"servers"`
}

A RespDirectory is the content of a response to GET /_matrix/federation/v1/query/directory This is returned when looking up a room alias from a remote server. See https://matrix.org/docs/spec/server_server/unstable.html#directory

type RespEventAuth

type RespEventAuth struct {
	// A list of events needed to authenticate the state events.
	AuthEvents gomatrixserverlib.EventJSONs `json:"auth_chain"`
}

A RespEventAuth is the content of a response to GET /_matrix/federation/v1/event_auth/{roomID}/{eventID}

type RespGetRelayTransaction

type RespGetRelayTransaction struct {
	Transaction   gomatrixserverlib.Transaction `json:"transaction"`
	EntryID       int64                         `json:"entry_id,omitempty"`
	EntriesQueued bool                          `json:"entries_queued"`
}

A RespGetRelayTransaction is the response body of a successful GET to /_matrix/federation/v1/relay_txn/{userID}

type RespInvite

type RespInvite struct {
	// The invite event signed by recipient server.
	Event spec.RawJSON `json:"event"`
}

RespInvite is the content of a response to PUT /_matrix/federation/v1/invite/{roomID}/{eventID}

func (RespInvite) MarshalJSON

func (r RespInvite) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

func (*RespInvite) UnmarshalJSON

func (r *RespInvite) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaller

type RespInviteV2

type RespInviteV2 struct {
	// The invite event signed by recipient server.
	Event spec.RawJSON `json:"event"`
}

RespInvite is the content of a response to PUT /_matrix/federation/v2/invite/{roomID}/{eventID}

type RespMakeJoin

type RespMakeJoin struct {
	// An incomplete m.room.member event for a user on the requesting server
	// generated by the responding server.
	// See https://matrix.org/docs/spec/server_server/unstable.html#joining-rooms
	JoinEvent   gomatrixserverlib.ProtoEvent  `json:"event"`
	RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
}

A RespMakeJoin is the content of a response to GET /_matrix/federation/v2/make_join/{roomID}/{userID}

func (*RespMakeJoin) GetJoinEvent

func (r *RespMakeJoin) GetJoinEvent() gomatrixserverlib.ProtoEvent

func (*RespMakeJoin) GetRoomVersion

func (r *RespMakeJoin) GetRoomVersion() gomatrixserverlib.RoomVersion

type RespMakeKnock

type RespMakeKnock struct {
	// An incomplete m.room.member event for a user on the requesting server
	// generated by the responding server.
	// See https://spec.matrix.org/v1.3/server-server-api/#knocking-upon-a-room
	KnockEvent  gomatrixserverlib.ProtoEvent  `json:"event"`
	RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
}

A RespMakeKnock is the content of a response to GET /_matrix/federation/v2/make_knock/{roomID}/{userID}

type RespMakeLeave

type RespMakeLeave struct {
	// An incomplete m.room.member event for a user on the requesting server
	// generated by the responding server.
	// See https://matrix.org/docs/spec/server_server/r0.1.1.html#get-matrix-federation-v1-make-leave-roomid-userid
	LeaveEvent gomatrixserverlib.ProtoEvent `json:"event"`
	// The room version that we're trying to leave.
	RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
}

A RespMakeLeave is the content of a response to GET /_matrix/federation/v2/make_leave/{roomID}/{userID}

type RespMissingEvents

type RespMissingEvents struct {
	// The returned set of missing events.
	Events gomatrixserverlib.EventJSONs `json:"events"`
}

A RespMissingEvents is the content of a response to GET /_matrix/federation/v1/get_missing_events/{roomID}

type RespPeek

type RespPeek struct {
	// How often should we renew the peek?
	RenewalInterval int64 `json:"renewal_interval"`
	// A list of events giving the state of the room at the point of the request
	StateEvents gomatrixserverlib.EventJSONs `json:"state"`
	// A list of events needed to authenticate the state events.
	AuthEvents gomatrixserverlib.EventJSONs `json:"auth_chain"`
	// The room version that we're trying to peek.
	RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
	// The ID of the event whose state snapshot this is - i.e. the
	// most recent forward extremity in the room.
	LatestEvent gomatrixserverlib.PDU `json:"latest_event"`
}

A RespPeek is the content of a response to GET /_matrix/federation/v1/peek/{roomID}/{peekID}

func (*RespPeek) GetAuthEvents

func (r *RespPeek) GetAuthEvents() gomatrixserverlib.EventJSONs

func (*RespPeek) GetStateEvents

func (r *RespPeek) GetStateEvents() gomatrixserverlib.EventJSONs

func (RespPeek) MarshalJSON

func (r RespPeek) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

type RespProfile

type RespProfile struct {
	DisplayName string `json:"displayname,omitempty"`
	AvatarURL   string `json:"avatar_url,omitempty"`
}

RespProfile is the content of a response to GET /_matrix/federation/v1/query/profile

type RespPublicRooms

type RespPublicRooms struct {
	// A paginated chunk of public rooms.
	Chunk []PublicRoom `json:"chunk"`
	// A pagination token for the response. The absence of this token means there are no more results to fetch and the client should stop paginating.
	NextBatch string `json:"next_batch,omitempty"`
	// A pagination token that allows fetching previous results. The absence of this token means there are no results before this batch, i.e. this is the first batch.
	PrevBatch string `json:"prev_batch,omitempty"`
	// An estimate on the total number of public rooms, if the server has an estimate.
	TotalRoomCountEstimate int `json:"total_room_count_estimate,omitempty"`
}

RespPublicRooms is the content of a response to GET /_matrix/federation/v1/publicRooms

type RespQueryKeys

type RespQueryKeys struct {
	DeviceKeys      map[string]map[string]DeviceKeys `json:"device_keys"`
	MasterKeys      map[string]CrossSigningKey       `json:"master_keys"`
	SelfSigningKeys map[string]CrossSigningKey       `json:"self_signing_keys"`
}

RespQueryKeys is the response for https://matrix.org/docs/spec/server_server/latest#post-matrix-federation-v1-user-keys-query

type RespSend

type RespSend struct {
	// Map of event ID to the result of processing that event.
	PDUs map[string]PDUResult `json:"pdus"`
}

A RespSend is the content of a response to PUT /_matrix/federation/v1/send/{txnID}/

type RespSendJoin

type RespSendJoin struct {
	// A list of events giving the state of the room before the request event.
	StateEvents gomatrixserverlib.EventJSONs `json:"state"`
	// A list of events needed to authenticate the state events.
	AuthEvents gomatrixserverlib.EventJSONs `json:"auth_chain"`
	// The server that originated the event.
	Origin spec.ServerName `json:"origin"`
	// The returned join event from the remote server. Used for restricted joins,
	// but not guaranteed to be present as it's only since MSC3083.
	Event spec.RawJSON `json:"event,omitempty"`
	// true if the state is incomplete
	MembersOmitted bool `json:"members_omitted"`
	// a list of servers in the room. Only returned if partial_state is set.
	ServersInRoom []string `json:"servers_in_room"`
}

A RespSendJoin is the content of a response to PUT /_matrix/federation/v2/send_join/{roomID}/{eventID}

func (*RespSendJoin) GetAuthEvents

func (r *RespSendJoin) GetAuthEvents() gomatrixserverlib.EventJSONs

func (*RespSendJoin) GetJoinEvent

func (r *RespSendJoin) GetJoinEvent() spec.RawJSON

func (*RespSendJoin) GetMembersOmitted

func (r *RespSendJoin) GetMembersOmitted() bool

func (*RespSendJoin) GetOrigin

func (r *RespSendJoin) GetOrigin() spec.ServerName

func (*RespSendJoin) GetServersInRoom

func (r *RespSendJoin) GetServersInRoom() []string

func (*RespSendJoin) GetStateEvents

func (r *RespSendJoin) GetStateEvents() gomatrixserverlib.EventJSONs

func (RespSendJoin) MarshalJSON

func (r RespSendJoin) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

type RespSendKnock

type RespSendKnock struct {
	// A list of stripped state events to help the initiator of the knock identify the room.
	KnockRoomState []gomatrixserverlib.InviteStrippedState `json:"knock_room_state"`
}

A RespSendKnock is the content of a response to PUT /_matrix/federation/v2/send_knock/{roomID}/{eventID}

type RespState

type RespState struct {
	// A list of events giving the state of the room before the request event.
	StateEvents gomatrixserverlib.EventJSONs `json:"pdus"`
	// A list of events needed to authenticate the state events.
	AuthEvents gomatrixserverlib.EventJSONs `json:"auth_chain"`
}

A RespState is the content of a response to GET /_matrix/federation/v1/state/{roomID}/{eventID}

func (*RespState) GetAuthEvents

func (r *RespState) GetAuthEvents() gomatrixserverlib.EventJSONs

func (*RespState) GetStateEvents

func (r *RespState) GetStateEvents() gomatrixserverlib.EventJSONs

func (RespState) MarshalJSON

func (r RespState) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

type RespStateIDs

type RespStateIDs struct {
	// A list of state event IDs for the state of the room before the requested event.
	StateEventIDs []string `json:"pdu_ids"`
	// A list of event IDs needed to authenticate the state events.
	AuthEventIDs []string `json:"auth_chain_ids"`
}

A RespStateIDs is the content of a response to GET /_matrix/federation/v1/state_ids/{roomID}/{eventID}

func (RespStateIDs) GetAuthEventIDs

func (r RespStateIDs) GetAuthEventIDs() []string

func (RespStateIDs) GetStateEventIDs

func (r RespStateIDs) GetStateEventIDs() []string

type RespUserDevice

type RespUserDevice struct {
	DeviceID    string             `json:"device_id"`
	DisplayName string             `json:"device_display_name"`
	Keys        RespUserDeviceKeys `json:"keys"`
}

RespUserDevice are embedded in RespUserDevices https://matrix.org/docs/spec/server_server/latest#get-matrix-federation-v1-user-devices-userid

type RespUserDeviceKeys

type RespUserDeviceKeys struct {
	UserID     string   `json:"user_id"`
	DeviceID   string   `json:"device_id"`
	Algorithms []string `json:"algorithms"`
	// E.g "curve25519:JLAFKJWSCS": "3C5BFWi2Y8MaVvjM8M22DBmh24PmgR0nPvJOIArzgyI"
	Keys map[gomatrixserverlib.KeyID]spec.Base64Bytes `json:"keys"`
	// E.g "@alice:example.com": {
	//	"ed25519:JLAFKJWSCS": "dSO80A01XiigH3uBiDVx/EjzaoycHcjq9lfQX0uWsqxl2giMIiSPR8a4d291W1ihKJL/a+myXS367WT6NAIcBA"
	// }
	Signatures map[string]map[gomatrixserverlib.KeyID]spec.Base64Bytes `json:"signatures"`
}

RespUserDeviceKeys are embedded in RespUserDevice https://matrix.org/docs/spec/server_server/latest#get-matrix-federation-v1-user-devices-userid

type RespUserDevices

type RespUserDevices struct {
	UserID         string           `json:"user_id"`
	StreamID       int64            `json:"stream_id"`
	Devices        []RespUserDevice `json:"devices"`
	MasterKey      *CrossSigningKey `json:"master_key"`
	SelfSigningKey *CrossSigningKey `json:"self_signing_key"`
}

RespUserDevices contains a response to /_matrix/federation/v1/user/devices/{userID} https://matrix.org/docs/spec/server_server/latest#get-matrix-federation-v1-user-devices-userid

func (*RespUserDevices) UnmarshalJSON

func (r *RespUserDevices) UnmarshalJSON(data []byte) error

UnmarshalJSON is used here because people on Synapses can apparently upload nonsense into their device keys in types that don't match the expected and that can cause the entire response to fail to unmarshal. This simply skips anything that fails to unmarshal and returns the rest.

type RoomHierarchyResponse

type RoomHierarchyResponse struct {
	Room                 RoomHierarchyRoom   `json:"room"`
	Children             []RoomHierarchyRoom `json:"children"`
	InaccessibleChildren []string            `json:"inaccessible_children"`
}

RoomHierarchyResponse is the HTTP response body for the federation /unstable/spaces/{roomID} endpoint See https://github.com/matrix-org/matrix-doc/pull/2946

type RoomHierarchyRoom

type RoomHierarchyRoom struct {
	PublicRoom
	ChildrenState  []RoomHierarchyStrippedEvent `json:"children_state"`
	AllowedRoomIDs []string                     `json:"allowed_room_ids,omitempty"`
	RoomType       string                       `json:"room_type"`
}

RoomHierarchyRoom represents a public room with additional metadata on the space directory

type RoomHierarchyStrippedEvent

type RoomHierarchyStrippedEvent struct {
	Type           string          `json:"type"`
	StateKey       string          `json:"state_key"`
	Content        json.RawMessage `json:"content"`
	Sender         string          `json:"sender"`
	OriginServerTS spec.Timestamp  `json:"origin_server_ts"`
}

RoomHierarchyStrippedEvent is the format of events returned in the HTTP response body

type SigningIdentity

type SigningIdentity struct {
	// YAML annotations so it can be used directly in Dendrite config.
	ServerName spec.ServerName         `yaml:"server_name"`
	KeyID      gomatrixserverlib.KeyID `yaml:"key_id"`
	PrivateKey ed25519.PrivateKey      `yaml:"-"`
}

type UserInfo

type UserInfo struct {
	Sub string `json:"sub"`
}

UserInfo represents information about a user.

type Version

type Version struct {
	// Server is a struct containing the homserver version values
	Server struct {
		// Name is an arbitrary string that the Matrix server uses to identify itself
		Name string `json:"name"`
		// Version is a string that identifies the Matrix server's version, the format
		// of which depends on the Matrx server implementation
		Version string `json:"version"`
	} `json:"server"`
}

A Version is a struct that matches the version response from a Matrix homeserver. See https://matrix.org/docs/spec/server_server/r0.1.1.html#get-matrix-federation-v1-version

type WellKnownResult

type WellKnownResult struct {
	NewAddress     spec.ServerName `json:"m.server"`
	CacheExpiresAt int64
}

WellKnownResult is the result of looking up a matrix server's well-known file. Located at https://<server_name>/.well-known/matrix/server

func LookupWellKnown

func LookupWellKnown(ctx context.Context, serverNameType spec.ServerName) (*WellKnownResult, error)

LookupWellKnown looks up a well-known record for a matrix server. If one if found, it returns the server to redirect to.

Jump to

Keyboard shortcuts

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