threepid

package
v0.13.5 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: Apache-2.0 Imports: 18 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckAndProcessInvite

func CheckAndProcessInvite(
	ctx context.Context,
	device *userapi.Device, body *MembershipRequest, cfg *config.ClientAPI,
	rsAPI api.ClientRoomserverAPI, db userapi.ClientUserAPI,
	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,
	client *fclient.Client,
) (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, client *fclient.Client,
) (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(ctx context.Context, creds Credentials, userID string, cfg *config.ClientAPI, client *fclient.Client) 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:"three_pid_creds"`
	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 ErrMissingParameter

type ErrMissingParameter struct{}

ErrMissingParameter is the error raised if a request for 3PID invite has an incomplete body

func (ErrMissingParameter) Error added in v0.13.0

func (e ErrMissingParameter) Error() string

func (ErrMissingParameter) Unwrap added in v0.13.0

func (e ErrMissingParameter) Unwrap() error

type ErrNotTrusted

type ErrNotTrusted struct{}

ErrNotTrusted is the error raised if an identity server isn't in the list of trusted servers in the configuration file.

func (ErrNotTrusted) Error added in v0.13.0

func (e ErrNotTrusted) Error() string

func (ErrNotTrusted) Unwrap added in v0.13.0

func (e ErrNotTrusted) Unwrap() error

type GetValidatedResponse added in v0.13.0

type GetValidatedResponse struct {
	Medium      string `json:"medium"`
	ValidatedAt int64  `json:"validated_at"`
	Address     string `json:"address"`
	ErrCode     string `json:"errcode"`
	Error       string `json:"error"`
}

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)

type SID added in v0.13.0

type SID struct {
	SID string `json:"sid"`
}

Jump to

Keyboard shortcuts

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