mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
don't throw when trying to restore session from backup, check sender key
This commit is contained in:
parent
a205ae8841
commit
915925d6ee
@ -137,22 +137,25 @@ export class RoomEncryption {
|
||||
let eventIds = this._eventIdsByMissingSession.get(key);
|
||||
// new missing session
|
||||
if (!eventIds) {
|
||||
this._requestMissingSessionFromBackup(sessionId).catch(err => {
|
||||
console.error(`Could not get session ${sessionId} from backup`, err);
|
||||
});
|
||||
this._requestMissingSessionFromBackup(senderKey, sessionId);
|
||||
eventIds = new Set();
|
||||
this._eventIdsByMissingSession.set(key, eventIds);
|
||||
}
|
||||
eventIds.add(event.event_id);
|
||||
}
|
||||
|
||||
async _requestMissingSessionFromBackup(sessionId) {
|
||||
async _requestMissingSessionFromBackup(senderKey, sessionId) {
|
||||
if (!this._sessionBackup) {
|
||||
// somehow prompt for passphrase here
|
||||
this._notifyMissingMegolmSession();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const session = await this._sessionBackup.getSession(this._room.id, sessionId);
|
||||
if (session?.algorithm === MEGOLM_ALGORITHM) {
|
||||
if (session["sender_key"] !== senderKey) {
|
||||
console.warn("Got session key back from backup with different sender key, ignoring", {session, senderKey});
|
||||
return;
|
||||
}
|
||||
const txn = await this._storage.readWriteTxn([this._storage.storeNames.inboundGroupSessions]);
|
||||
let roomKey;
|
||||
try {
|
||||
@ -171,6 +174,9 @@ export class RoomEncryption {
|
||||
} else if (session?.algorithm) {
|
||||
console.info(`Backed-up session of unknown algorithm: ${session.algorithm}`);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Could not get session ${sessionId} from backup`, err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user