sqlite3

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

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 (d *Database) GetDevicesByID(ctx context.Context, deviceIDs []string) ([]api.Device, error)

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

func (d *Database) RemoveDevice(
	ctx context.Context, deviceID, localpart string,
) error

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

func (d *Database) RemoveDevices(
	ctx context.Context, localpart string, devices []string,
) error

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.

func (*Database) UpdateDevice

func (d *Database) UpdateDevice(
	ctx context.Context, localpart, deviceID string, displayName *string,
) error

UpdateDevice updates the given device with the display name. Returns SQL error if there are problems and nil on success.

func (*Database) UpdateDeviceLastSeen added in v0.2.0

func (d *Database) UpdateDeviceLastSeen(ctx context.Context, localpart, deviceID, ipAddr string) error

UpdateDeviceLastSeen updates a the last seen timestamp and the ip address

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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