devicestate

package
v1.21.1 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package devicestate owns consistent device removal shared by user and admin entry points. Redis generations revoke sessions; the database transaction removes both copies of the device identity. It also keeps the presence the device WebSocket reports: the online flag and the online time of each connection.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ctx context.Context, store Store, client *redis.Client, id, ownerID int64) (*user.Device, error)

Delete removes the device id with its identity and ends its sessions, in one identity transaction, and returns the removed device; a device that does not exist is no error and returns nil. A positive ownerID refuses a device of another account.

func MarkOffline added in v1.21.0

func MarkOffline(ctx context.Context, devices repository.UserDeviceRepo, userID int64, identifier string, connectedAt time.Time) error

MarkOffline shows the device identifier offline once its connection, opened at connectedAt, closed, and records the connection's online time for the account userID. The connection ended whether or not the flag could be cleared, so its online time is recorded either way. A device removed meanwhile is skipped.

func MarkOnline added in v1.21.0

func MarkOnline(ctx context.Context, devices repository.UserDeviceRepo, identifier string) error

MarkOnline shows the device identifier online once it connected to the device WebSocket. A device removed meanwhile is skipped, and a disabled one stays offline: the repository sets only enabled devices online.

Types

type Store added in v1.20.3

type Store interface {
	repository.IdentityTransactor
}

Store is the persistence capability required by this package. It excludes unrelated repositories and application-wide transactions.

Jump to

Keyboard shortcuts

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