mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-08 15:33:09 -06:00
Self-review
This commit is contained in:
parent
b29725ab13
commit
4e0c1924a6
|
|
@ -26,15 +26,15 @@ import (
|
|||
const devicesSchema = `
|
||||
-- Stores data about devices.
|
||||
CREATE TABLE IF NOT EXISTS devices (
|
||||
-- The access token granted to this device. This has to be the primary key
|
||||
-- so we can distinguish which device is making a given request.
|
||||
access_token TEXT NOT NULL PRIMARY KEY,
|
||||
-- The device identifier. This only needs to uniquely identify a device for a given user, not globally.
|
||||
-- access_tokens will be clobbered based on the device ID for a user.
|
||||
id TEXT NOT NULL,
|
||||
-- The Matrix user ID localpart for this device. This is preferable to storing the full user_id
|
||||
-- as it is smaller, makes it clearer that we only manage devices for our own users, and may make
|
||||
-- migration to different domain names easier.
|
||||
-- The access token granted to this device. This has to be the primary key
|
||||
-- so we can distinguish which device is making a given request.
|
||||
access_token TEXT NOT NULL PRIMARY KEY,
|
||||
-- The device identifier. This only needs to uniquely identify a device for a given user, not globally.
|
||||
-- access_tokens will be clobbered based on the device ID for a user.
|
||||
id TEXT NOT NULL,
|
||||
-- The Matrix user ID localpart for this device. This is preferable to storing the full user_id
|
||||
-- as it is smaller, makes it clearer that we only manage devices for our own users, and may make
|
||||
-- migration to different domain names easier.
|
||||
localpart TEXT NOT NULL,
|
||||
-- When this devices was first recognised on the network, as a unix timestamp (ms resolution).
|
||||
created_ts BIGINT NOT NULL
|
||||
|
|
@ -54,7 +54,7 @@ const selectDeviceByTokenSQL = "" +
|
|||
const deleteDeviceSQL = "" +
|
||||
"DELETE FROM devices WHERE id = $1 AND localpart = $2"
|
||||
|
||||
// TODO: List devices, delete device API
|
||||
// TODO: List devices?
|
||||
|
||||
type devicesStatements struct {
|
||||
insertDeviceStmt *sql.Stmt
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ func (d *Database) CreateDevice(localpart, deviceID string) (dev *authtypes.Devi
|
|||
return
|
||||
}
|
||||
|
||||
// TODO: factor out to common
|
||||
func runTransaction(db *sql.DB, fn func(txn *sql.Tx) error) (err error) {
|
||||
txn, err := db.Begin()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue