devices

package
v0.0.0-...-9835270 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2021 License: AGPL-3.0, Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatabase

func NewDatabase(driver, createAddr, address, underlying, topic string, useAsync bool) (interface{}, error)

NewDatabase creates a new device database

Types

type Database

type Database struct {
	AsyncSave bool
	// contains filtered or unexported fields
}

Database represents a device database.

func (*Database) CheckDevice

func (d *Database) CheckDevice(
	ctx context.Context, identifier, userID string,
) (string, string, int64, error)

func (*Database) CreateDevice

func (d *Database) CreateDevice(
	ctx context.Context, userID, deviceID, deviceType string,
	displayName *string, isHuman bool, identifier *string, specifiedTime int64,
) (dev *authtypes.Device, returnErr error)

CreateDevice makes a new device associated with the given user ID. 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) CreateMigDevice

func (d *Database) CreateMigDevice(
	ctx context.Context, userID, deviceID, token, migToken string,
) error

func (*Database) GetDeviceTotal

func (d *Database) GetDeviceTotal(
	ctx context.Context,
) (int, error)

func (*Database) InsertDevice

func (d *Database) InsertDevice(
	ctx context.Context, userID string, deviceID *string,
	displayName *string, deviceType, identifier string,
) error

func (*Database) LoadFilterData

func (d *Database) LoadFilterData(ctx context.Context, key string, f *filter.Filter) bool

func (*Database) LoadSimpleFilterData

func (d *Database) LoadSimpleFilterData(ctx context.Context, f *filter.SimpleFilter) bool

func (*Database) OnDeleteDevice

func (d *Database) OnDeleteDevice(
	ctx context.Context, deviceID, userID string, createTs int64,
) error

func (*Database) OnInsertDevice

func (d *Database) OnInsertDevice(
	ctx context.Context, userID string, deviceID *string,
	displayName *string, createdTs, lastActiveTs int64, deviceType, identifier string,
) error

func (*Database) OnInsertMigDevice

func (d *Database) OnInsertMigDevice(
	ctx context.Context, access_token, mig_access_token, deviceID, userID string,
) error

func (*Database) OnUpdateDeviceActiveTs

func (d *Database) OnUpdateDeviceActiveTs(
	ctx context.Context, deviceID, userID string, lastActiveTs int64,
) error

func (*Database) RecoverCache

func (d *Database) RecoverCache()

func (*Database) RemoveAllUserMigDevices

func (d *Database) RemoveAllUserMigDevices(
	ctx context.Context, userID string,
) error

func (*Database) RemoveDevice

func (d *Database) RemoveDevice(
	ctx context.Context, deviceID, userID string, createTs int64,
) error

RemoveDevice revokes a device by deleting the entry in the database matching with the given device ID and user ID 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) RemoveMigDevice

func (d *Database) RemoveMigDevice(
	ctx context.Context, deviceID, userID string,
) error

func (*Database) SelectUnActiveDevice

func (d *Database) SelectUnActiveDevice(
	ctx context.Context, lastActiveTs int64, limit, offset int,
) ([]string, []string, []string, int, error)

func (*Database) SetGauge

func (d *Database) SetGauge(qryDBGauge mon.LabeledGauge)

func (*Database) UpdateDeviceActiveTs

func (d *Database) UpdateDeviceActiveTs(
	ctx context.Context, deviceID, userID string, lastActiveTs int64,
) error

func (*Database) WriteDBEvent

func (d *Database) WriteDBEvent(ctx context.Context, update *dbtypes.DBEvent) error

WriteOutputEvents implements OutputRoomEventWriter

func (*Database) WriteDBEventWithTbl

func (d *Database) WriteDBEventWithTbl(ctx context.Context, update *dbtypes.DBEvent, tbl string) error

Jump to

Keyboard shortcuts

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