put key session check in method

This commit is contained in:
Bruno Windels 2021-10-26 11:14:46 +02:00
parent 805c2657f2
commit 67dd929951
2 changed files with 5 additions and 1 deletions

View file

@ -109,7 +109,7 @@ export class Decryption {
private async getRoomKey(roomId: string, senderKey: string, sessionId: string, newKeys: IncomingRoomKey[] | undefined, txn: Transaction): Promise<RoomKey | undefined> {
if (newKeys) {
const key = newKeys.find(k => k.roomId === roomId && k.senderKey === senderKey && k.sessionId === sessionId);
const key = newKeys.find(k => k.isForSession(roomId, senderKey, sessionId));
if (key && await key.checkBetterThanKeyInStorage(this.keyLoader, txn)) {
return key;
}

View file

@ -22,6 +22,10 @@ import type {KeyLoader, OlmInboundGroupSession} from "./KeyLoader";
export abstract class RoomKey {
private _isBetter: boolean | undefined;
isForSession(roomId: string, senderKey: string, sessionId: string) {
return this.roomId === roomId && this.senderKey === senderKey && this.sessionId === sessionId;
}
abstract get roomId(): string;
abstract get senderKey(): string;
abstract get sessionId(): string;