move some validation of into session backup

This commit is contained in:
Bruno Windels 2022-01-25 18:48:03 +01:00
parent 8f4e3c62ce
commit ffece4f357

View File

@ -182,9 +182,7 @@ export class RoomEncryption {
log.set("id", sessionId); log.set("id", sessionId);
log.set("senderKey", senderKey); log.set("senderKey", senderKey);
try { try {
const session = await this._sessionBackup.getSession(this._room.id, sessionId, log); const roomKey = await this._sessionBackup.getRoomKey(this._room.id, sessionId, log);
if (session?.algorithm === MEGOLM_ALGORITHM) {
let roomKey = this._megolmDecryption.roomKeyFromBackup(this._room.id, sessionId, session);
if (roomKey) { if (roomKey) {
if (roomKey.senderKey !== senderKey) { if (roomKey.senderKey !== senderKey) {
log.set("wrong_sender_key", roomKey.senderKey); log.set("wrong_sender_key", roomKey.senderKey);
@ -209,9 +207,6 @@ export class RoomEncryption {
await log.wrap("retryDecryption", log => this._room.notifyRoomKey(roomKey, retryEventIds || [], log)); await log.wrap("retryDecryption", log => this._room.notifyRoomKey(roomKey, retryEventIds || [], log));
} }
} }
} else if (session?.algorithm) {
log.set("unknown algorithm", session.algorithm);
}
} catch (err) { } catch (err) {
if (!(err.name === "HomeServerError" && err.errcode === "M_NOT_FOUND")) { if (!(err.name === "HomeServerError" && err.errcode === "M_NOT_FOUND")) {
log.set("not_found", true); log.set("not_found", true);