SAMA-Communications / sama-server

SAMA - Simple but Advanced Messaging Alternative chat server, powered by uWebsockets.js
https://samacloud.io
GNU General Public License v3.0
110 stars 8 forks source link

SK-246 added `device_id` field for encryption device record #129

Closed Oleksandr1414 closed 1 month ago

Oleksandr1414 commented 1 month ago
IgorKhomenko commented 1 month ago

So we have a device_id field now.

I propose to integrate it further: 1) when list own devices, return device_id field instead of id 2) when delete device, also pass device_id instead of id 3) when list other user's keys - also return device_id instead of id

With this changes, it will be more consistent and users do not need to think what to use - device_id or id field.

Also, this index could be updated from

await db.collection("encrypted_devices").createIndex({ user_id: 1, identity_key: 1 }, { unique: true })

to

await db.collection("encrypted_devices").createIndex({ user_id: 1, device_id: 1 }, { unique: true })

Also, I see we have this request now const device = await this.findOne({ device_id }), so it worth adding another index await db.collection("encrypted_devices").createIndex({ device_id: 1 }) so the query will be fast

WDYT?