Documentation ¶
Index ¶
- type Database
- func (d *Database) CreateDevice(ctx context.Context, localpart string, deviceID *string, accessToken string, ...) (dev *api.Device, returnErr error)
- func (d *Database) GetDeviceByAccessToken(ctx context.Context, token string) (*api.Device, error)
- func (d *Database) GetDeviceByID(ctx context.Context, localpart, deviceID string) (*api.Device, error)
- func (d *Database) GetDevicesByID(ctx context.Context, deviceIDs []string) ([]api.Device, error)
- func (d *Database) GetDevicesByLocalpart(ctx context.Context, localpart string) ([]api.Device, error)
- func (d *Database) RemoveAllDevices(ctx context.Context, localpart, exceptDeviceID string) (devices []api.Device, err error)
- func (d *Database) RemoveDevice(ctx context.Context, deviceID, localpart string) error
- func (d *Database) RemoveDevices(ctx context.Context, localpart string, devices []string) error
- func (d *Database) UpdateDevice(ctx context.Context, localpart, deviceID string, displayName *string) error
- func (d *Database) UpdateDeviceLastSeen(ctx context.Context, localpart, deviceID, ipAddr string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database represents a device database.
func NewDatabase ¶
func NewDatabase(dbProperties *config.DatabaseOptions, serverName gomatrixserverlib.ServerName) (*Database, error)
NewDatabase creates a new device database
func (*Database) CreateDevice ¶
func (d *Database) CreateDevice( ctx context.Context, localpart string, deviceID *string, accessToken string, displayName *string, ipAddr, userAgent string, ) (dev *api.Device, returnErr error)
CreateDevice makes a new device associated with the given user ID localpart. If there is already a device with the same device ID for this user, that access token will be revoked and replaced with the given accessToken. If the given accessToken is already in use for another device, an error will be returned. If no device ID is given one is generated. Returns the device on success.
func (*Database) GetDeviceByAccessToken ¶
func (d *Database) GetDeviceByAccessToken( ctx context.Context, token string, ) (*api.Device, error)
GetDeviceByAccessToken returns the device matching the given access token. Returns sql.ErrNoRows if no matching device was found.
func (*Database) GetDeviceByID ¶
func (d *Database) GetDeviceByID( ctx context.Context, localpart, deviceID string, ) (*api.Device, error)
GetDeviceByID returns the device matching the given ID. Returns sql.ErrNoRows if no matching device was found.
func (*Database) GetDevicesByID ¶
func (*Database) GetDevicesByLocalpart ¶
func (d *Database) GetDevicesByLocalpart( ctx context.Context, localpart string, ) ([]api.Device, error)
GetDevicesByLocalpart returns the devices matching the given localpart.
func (*Database) RemoveAllDevices ¶
func (d *Database) RemoveAllDevices( ctx context.Context, localpart, exceptDeviceID string, ) (devices []api.Device, err error)
RemoveAllDevices revokes devices by deleting the entry in the database matching the given user ID localpart. If something went wrong during the deletion, it will return the SQL error.
func (*Database) RemoveDevice ¶
RemoveDevice revokes a device by deleting the entry in the database matching with the given device ID and user ID localpart. If the device doesn't exist, it will not return an error If something went wrong during the deletion, it will return the SQL error.
func (*Database) RemoveDevices ¶
RemoveDevices revokes one or more devices by deleting the entry in the database matching with the given device IDs and user ID localpart. If the devices don't exist, it will not return an error If something went wrong during the deletion, it will return the SQL error.