Implement devices API (#20)

small improvements

Cargo fmt

Simplify insert and update methods

Review feedback

Remove has_device method calls

Load all devices with a single db call

Remove device as in logout

Put all metadata on the same tree

Create userdevice key fucntion

Implement devices API

Implement all the devices endpoints. There's a couple of pending tasks:

- Integrate the "logout" logic once it lands to master (this should
  remove the given device from the database).
- Track and store last seen timestamp and IP.

Co-authored-by: timokoesters <timo@koesters.xyz>
Co-authored-by: Guillem Nieto <gnieto.talo@gmail.com>
This commit is contained in:
gnieto 2020-06-03 13:41:30 +02:00 committed by timokoesters
parent ed9b544ace
commit 0883c44659
No known key found for this signature in database
GPG Key ID: 356E705610F626D5
1 changed files with 1 additions and 1 deletions

View File

@ -430,7 +430,7 @@ impl Users {
userdeviceid.push(0xff);
userdeviceid.extend_from_slice(device_id.as_bytes());
if self.userdeviceid_metadata.get(userdeviceid)?.is_none() {
if self.userdeviceid_metadata.get(&userdeviceid)?.is_none() {
return Err(Error::BadRequest("device does not exist"));
}