mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 12:28:50 +03:00
Wrap canEncryptToAllUsers in a try/catch to handle server errors
Fixes https://github.com/vector-im/element-web/issues/12266
This commit is contained in:
parent
c6834fd428
commit
60d5e732d9
1 changed files with 11 additions and 6 deletions
|
@ -275,12 +275,17 @@ export async function _waitForMember(client: MatrixClient, roomId: string, userI
|
||||||
* can encrypt to.
|
* can encrypt to.
|
||||||
*/
|
*/
|
||||||
export async function canEncryptToAllUsers(client: MatrixClient, userIds: string[]) {
|
export async function canEncryptToAllUsers(client: MatrixClient, userIds: string[]) {
|
||||||
const usersDeviceMap = await client.downloadKeys(userIds);
|
try {
|
||||||
// { "@user:host": { "DEVICE": {...}, ... }, ... }
|
const usersDeviceMap = await client.downloadKeys(userIds);
|
||||||
return Object.values(usersDeviceMap).every((userDevices) =>
|
// { "@user:host": { "DEVICE": {...}, ... }, ... }
|
||||||
// { "DEVICE": {...}, ... }
|
return Object.values(usersDeviceMap).every((userDevices) =>
|
||||||
Object.keys(userDevices).length > 0,
|
// { "DEVICE": {...}, ... }
|
||||||
);
|
Object.keys(userDevices).length > 0,
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error determining if it's possible to encrypt to all users: ", e);
|
||||||
|
return false; // assume not
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function ensureDMExists(client: MatrixClient, userId: string): Promise<string> {
|
export async function ensureDMExists(client: MatrixClient, userId: string): Promise<string> {
|
||||||
|
|
Loading…
Reference in a new issue