api

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: Apache-2.0 Imports: 4 Imported by: 144

Documentation

Index

Constants

View Source
const (
	// ConflictUpdate will update matching records returning no error
	ConflictUpdate Conflict = 1
	// ConflictAbort will reject the request with ErrorConflict
	ConflictAbort Conflict = 2

	// AccountTypeUser indicates this is a user account
	AccountTypeUser AccountType = 1
	// AccountTypeGuest indicates this is a guest account
	AccountTypeGuest AccountType = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	UserID       string
	Localpart    string
	ServerName   gomatrixserverlib.ServerName
	AppServiceID string
}

Account represents a Matrix account on this home server.

type AccountType

type AccountType int

AccountType is an enum representing the kind of account

type Conflict

type Conflict int

Conflict is an enum representing what to do when encountering conflicting when creating profiles/devices

type Device

type Device struct {
	ID     string
	UserID string
	// The access_token granted to this device.
	// This uniquely identifies the device from all other devices and clients.
	AccessToken string
	// The unique ID of the session identified by the access token.
	// Can be used as a secure substitution in places where data needs to be
	// associated with access tokens.
	SessionID   int64
	DisplayName string
	LastSeenTS  int64
	LastSeenIP  string
	UserAgent   string
}

Device represents a client's device (mobile, web, etc)

type ErrorConflict

type ErrorConflict struct {
	Message string
}

ErrorConflict is an error indicating that there was a conflict which resulted in the request being aborted.

func (*ErrorConflict) Error

func (e *ErrorConflict) Error() string

type ErrorForbidden

type ErrorForbidden struct {
	Message string
}

ErrorForbidden is an error indicating that the supplied access token is forbidden

func (*ErrorForbidden) Error

func (e *ErrorForbidden) Error() string

type InputAccountDataRequest

type InputAccountDataRequest struct {
	UserID      string          // required: the user to set account data for
	RoomID      string          // optional: the room to associate the account data with
	DataType    string          // required: the data type of the data
	AccountData json.RawMessage // required: the message content
}

InputAccountDataRequest is the request for InputAccountData

type InputAccountDataResponse

type InputAccountDataResponse struct {
}

InputAccountDataResponse is the response for InputAccountData

type PerformAccountCreationRequest

type PerformAccountCreationRequest struct {
	AccountType AccountType // Required: whether this is a guest or user account
	Localpart   string      // Required: The localpart for this account. Ignored if account type is guest.

	AppServiceID string // optional: the application service ID (not user ID) creating this account, if any.
	Password     string // optional: if missing then this account will be a passwordless account
	OnConflict   Conflict
}

PerformAccountCreationRequest is the request for PerformAccountCreation

type PerformAccountCreationResponse

type PerformAccountCreationResponse struct {
	AccountCreated bool
	Account        *Account
}

PerformAccountCreationResponse is the response for PerformAccountCreation

type PerformAccountDeactivationRequest

type PerformAccountDeactivationRequest struct {
	Localpart string
}

PerformAccountDeactivationRequest is the request for PerformAccountDeactivation

type PerformAccountDeactivationResponse

type PerformAccountDeactivationResponse struct {
	AccountDeactivated bool
}

PerformAccountDeactivationResponse is the response for PerformAccountDeactivation

type PerformDeviceCreationRequest

type PerformDeviceCreationRequest struct {
	Localpart   string
	AccessToken string // optional: if blank one will be made on your behalf
	// optional: if nil an ID is generated for you. If set, replaces any existing device session,
	// which will generate a new access token and invalidate the old one.
	DeviceID *string
	// optional: if nil no display name will be associated with this device.
	DeviceDisplayName *string
	// IP address of this device
	IPAddr string
	// Useragent for this device
	UserAgent string
}

PerformDeviceCreationRequest is the request for PerformDeviceCreation

type PerformDeviceCreationResponse

type PerformDeviceCreationResponse struct {
	DeviceCreated bool
	Device        *Device
}

PerformDeviceCreationResponse is the response for PerformDeviceCreation

type PerformDeviceDeletionRequest

type PerformDeviceDeletionRequest struct {
	UserID string
	// The devices to delete. An empty slice means delete all devices.
	DeviceIDs []string
	// The requesting device ID to exclude from deletion. This is needed
	// so that a password change doesn't cause that client to be logged
	// out. Only specify when DeviceIDs is empty.
	ExceptDeviceID string
}

type PerformDeviceDeletionResponse

type PerformDeviceDeletionResponse struct {
}

type PerformDeviceUpdateRequest

type PerformDeviceUpdateRequest struct {
	RequestingUserID string
	DeviceID         string
	DisplayName      *string
}

type PerformDeviceUpdateResponse

type PerformDeviceUpdateResponse struct {
	DeviceExists bool
	Forbidden    bool
}

type PerformLastSeenUpdateRequest added in v0.3.1

type PerformLastSeenUpdateRequest struct {
	UserID     string
	DeviceID   string
	RemoteAddr string
}

PerformLastSeenUpdateRequest is the request for PerformLastSeenUpdate.

type PerformLastSeenUpdateResponse added in v0.3.1

type PerformLastSeenUpdateResponse struct {
}

PerformLastSeenUpdateResponse is the response for PerformLastSeenUpdate.

type PerformPasswordUpdateRequest

type PerformPasswordUpdateRequest struct {
	Localpart string // Required: The localpart for this account.
	Password  string // Required: The new password to set.
}

PerformAccountCreationRequest is the request for PerformAccountCreation

type PerformPasswordUpdateResponse

type PerformPasswordUpdateResponse struct {
	PasswordUpdated bool
	Account         *Account
}

PerformAccountCreationResponse is the response for PerformAccountCreation

type QueryAccessTokenRequest

type QueryAccessTokenRequest struct {
	AccessToken string
	// optional user ID, valid only if the token is an appservice.
	// https://matrix.org/docs/spec/application_service/r0.1.2#using-sync-and-events
	AppServiceUserID string
}

QueryAccessTokenRequest is the request for QueryAccessToken

type QueryAccessTokenResponse

type QueryAccessTokenResponse struct {
	Device *Device
	Err    error // e.g ErrorForbidden
}

QueryAccessTokenResponse is the response for QueryAccessToken

type QueryAccountDataRequest

type QueryAccountDataRequest struct {
	UserID   string // required: the user to get account data for.
	RoomID   string // optional: the room ID, or global account data if not specified.
	DataType string // optional: the data type, or all types if not specified.
}

QueryAccountDataRequest is the request for QueryAccountData

type QueryAccountDataResponse

type QueryAccountDataResponse struct {
	GlobalAccountData map[string]json.RawMessage            // type -> data
	RoomAccountData   map[string]map[string]json.RawMessage // room -> type -> data
}

QueryAccountDataResponse is the response for QueryAccountData

type QueryDeviceInfosRequest

type QueryDeviceInfosRequest struct {
	DeviceIDs []string
}

QueryDeviceInfosRequest is the request to QueryDeviceInfos

type QueryDeviceInfosResponse

type QueryDeviceInfosResponse struct {
	DeviceInfo map[string]struct {
		DisplayName string
		UserID      string
	}
}

QueryDeviceInfosResponse is the response to QueryDeviceInfos

type QueryDevicesRequest

type QueryDevicesRequest struct {
	UserID string
}

QueryDevicesRequest is the request for QueryDevices

type QueryDevicesResponse

type QueryDevicesResponse struct {
	UserExists bool
	Devices    []Device
}

QueryDevicesResponse is the response for QueryDevices

type QueryProfileRequest

type QueryProfileRequest struct {
	// The user ID to query
	UserID string
}

QueryProfileRequest is the request for QueryProfile

type QueryProfileResponse

type QueryProfileResponse struct {
	// True if the user exists. Querying for a profile does not create them.
	UserExists bool
	// The current display name if set.
	DisplayName string
	// The current avatar URL if set.
	AvatarURL string
}

QueryProfileResponse is the response for QueryProfile

type QuerySearchProfilesRequest

type QuerySearchProfilesRequest struct {
	// The search string to match
	SearchString string
	// How many results to return
	Limit int
}

QuerySearchProfilesRequest is the request for QueryProfile

type QuerySearchProfilesResponse

type QuerySearchProfilesResponse struct {
	// Profiles matching the search
	Profiles []authtypes.Profile
}

QuerySearchProfilesResponse is the response for QuerySearchProfilesRequest

type UserInternalAPI

type UserInternalAPI interface {
	InputAccountData(ctx context.Context, req *InputAccountDataRequest, res *InputAccountDataResponse) error
	PerformAccountCreation(ctx context.Context, req *PerformAccountCreationRequest, res *PerformAccountCreationResponse) error
	PerformPasswordUpdate(ctx context.Context, req *PerformPasswordUpdateRequest, res *PerformPasswordUpdateResponse) error
	PerformDeviceCreation(ctx context.Context, req *PerformDeviceCreationRequest, res *PerformDeviceCreationResponse) error
	PerformDeviceDeletion(ctx context.Context, req *PerformDeviceDeletionRequest, res *PerformDeviceDeletionResponse) error
	PerformLastSeenUpdate(ctx context.Context, req *PerformLastSeenUpdateRequest, res *PerformLastSeenUpdateResponse) error
	PerformDeviceUpdate(ctx context.Context, req *PerformDeviceUpdateRequest, res *PerformDeviceUpdateResponse) error
	PerformAccountDeactivation(ctx context.Context, req *PerformAccountDeactivationRequest, res *PerformAccountDeactivationResponse) error
	QueryProfile(ctx context.Context, req *QueryProfileRequest, res *QueryProfileResponse) error
	QueryAccessToken(ctx context.Context, req *QueryAccessTokenRequest, res *QueryAccessTokenResponse) error
	QueryDevices(ctx context.Context, req *QueryDevicesRequest, res *QueryDevicesResponse) error
	QueryAccountData(ctx context.Context, req *QueryAccountDataRequest, res *QueryAccountDataResponse) error
	QueryDeviceInfos(ctx context.Context, req *QueryDeviceInfosRequest, res *QueryDeviceInfosResponse) error
	QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error
}

UserInternalAPI is the internal API for information about users and devices.

Jump to

Keyboard shortcuts

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