mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
Add method to fetch device by curve key
This commit is contained in:
parent
e079a4d76c
commit
ed3772d67b
@ -595,6 +595,22 @@ export class DeviceTracker {
|
||||
return deviceKey;
|
||||
}
|
||||
|
||||
async deviceForCurveKey(userId: string, key: string, hsApi: HomeServerApi, log: ILogItem) {
|
||||
const txn = await this._storage.readTxn([
|
||||
this._storage.storeNames.deviceKeys,
|
||||
this._storage.storeNames.userIdentities,
|
||||
]);
|
||||
const userIdentity = await txn.userIdentities.get(userId);
|
||||
if (userIdentity?.keysTrackingStatus !== KeysTrackingStatus.UpToDate) {
|
||||
const {deviceKeys} = await this._queryKeys([userId], hsApi, log);
|
||||
const keyList = deviceKeys.get(userId);
|
||||
const device = keyList!.find(device => device.keys.curve25519 === key);
|
||||
return device;
|
||||
}
|
||||
const device = await txn.deviceKeys.getByCurve25519Key(key);
|
||||
return device;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the device identities with which keys should be shared for a set of users in a tracked room.
|
||||
* If any userIdentities are outdated, it will fetch them from the homeserver.
|
||||
|
Loading…
Reference in New Issue
Block a user