threepid

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: Apache-2.0 Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMissingParameter is the error raised if a request for 3PID invite has
	// an incomplete body
	ErrMissingParameter = errors.New("'address', 'id_server' and 'medium' must all be supplied")
	// ErrNotTrusted is the error raised if an identity server isn't in the list
	// of trusted servers in the configuration file.
	ErrNotTrusted = errors.New("untrusted server")
)

Functions

func CheckAndProcessInvite

func CheckAndProcessInvite(
	ctx context.Context,
	device *userapi.Device, body *MembershipRequest, cfg *config.ClientAPI,
	rsAPI api.RoomserverInternalAPI, db accounts.Database,
	roomID string,
	evTime time.Time,
) (inviteStoredOnIDServer bool, err error)

CheckAndProcessInvite analyses the body of an incoming membership request. If the fields relative to a third-party-invite are all supplied, lookups the matching Matrix ID from the given identity server. If no Matrix ID is associated to the given 3PID, asks the identity server to store the invite and emit a "m.room.third_party_invite" event. Returns a representation of the HTTP response to send to the user. Returns a representation of a non-200 HTTP response if something went wrong in the process, or if some 3PID fields aren't supplied but others are. If none of the 3PID-specific fields are supplied, or if a Matrix ID is supplied by the identity server, returns nil to indicate that the request must be processed as a non-3PID membership request. In the latter case, fills the Matrix ID in the request body so a normal invite membership event can be emitted.

func CheckAssociation

func CheckAssociation(
	ctx context.Context, creds Credentials, cfg *config.ClientAPI,
) (bool, string, string, error)

CheckAssociation checks the status of an ongoing association validation on an identity server. Returns a boolean set to true if the association has been validated, false if not. If the association has been validated, also returns the related third-party identifier and its medium. Returns an error if there was a problem sending the request or decoding the response, or if the identity server responded with a non-OK status.

func CreateSession

func CreateSession(
	ctx context.Context, req EmailAssociationRequest, cfg *config.ClientAPI,
) (string, error)

CreateSession creates a session on an identity server. Returns the session's ID. Returns an error if there was a problem sending the request or decoding the response, or if the identity server responded with a non-OK status.

func PublishAssociation

func PublishAssociation(creds Credentials, userID string, cfg *config.ClientAPI) error

PublishAssociation publishes a validated association between a third-party identifier and a Matrix ID. Returns an error if there was a problem sending the request or decoding the response, or if the identity server responded with a non-OK status.

Types

type Credentials

type Credentials struct {
	SID      string `json:"sid"`
	IDServer string `json:"id_server"`
	Secret   string `json:"client_secret"`
}

Credentials represents the "ThreePidCredentials" structure defined at https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-3pid

type EmailAssociationCheckRequest

type EmailAssociationCheckRequest struct {
	Creds Credentials `json:"threePidCreds"`
	Bind  bool        `json:"bind"`
}

EmailAssociationCheckRequest represents the request defined at https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-account-3pid

type EmailAssociationRequest

type EmailAssociationRequest struct {
	IDServer    string `json:"id_server"`
	Secret      string `json:"client_secret"`
	Email       string `json:"email"`
	SendAttempt int    `json:"send_attempt"`
}

EmailAssociationRequest represents the request defined at https://matrix.org/docs/spec/client_server/r0.2.0.html#post-matrix-client-r0-register-email-requesttoken

type MembershipRequest

type MembershipRequest struct {
	UserID   string `json:"user_id"`
	Reason   string `json:"reason"`
	IDServer string `json:"id_server"`
	Medium   string `json:"medium"`
	Address  string `json:"address"`
}

MembershipRequest represents the body of an incoming POST request on /rooms/{roomID}/(join|kick|ban|unban|leave|invite)

Jump to

Keyboard shortcuts

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