Add interface method and implement it

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>
This commit is contained in:
Till Faelligen 2020-10-01 22:05:46 +02:00
parent 5c921476f9
commit 754630a014
3 changed files with 15 additions and 0 deletions

View file

@ -37,4 +37,5 @@ type Database interface {
RemoveDevices(ctx context.Context, localpart string, devices []string) error
// RemoveAllDevices deleted all devices for this user. Returns the devices deleted.
RemoveAllDevices(ctx context.Context, localpart, exceptDeviceID string) (devices []api.Device, err error)
UpdateDeviceLastSeen(ctx context.Context, deviceID, ipAddr string) error
}

View file

@ -189,3 +189,10 @@ func (d *Database) RemoveAllDevices(
})
return
}
// UpdateDeviceLastSeen updates a the last seen timestamp and the ip address
func (d *Database) UpdateDeviceLastSeen(ctx context.Context, deviceID, ipAddr string) error {
return sqlutil.WithTransaction(d.db, func(txn *sql.Tx) error {
return d.devices.updateDeviceLastSeen(ctx, txn, deviceID, ipAddr)
})
}

View file

@ -193,3 +193,10 @@ func (d *Database) RemoveAllDevices(
})
return
}
// UpdateDeviceLastSeen updates a the last seen timestamp and the ip address
func (d *Database) UpdateDeviceLastSeen(ctx context.Context, deviceID, ipAddr string) error {
return sqlutil.WithTransaction(d.db, func(txn *sql.Tx) error {
return d.devices.updateDeviceLastSeen(ctx, txn, deviceID, ipAddr)
})
}