forked from mystiq/hydrogen-web
put key session check in method
This commit is contained in:
parent
805c2657f2
commit
67dd929951
2 changed files with 5 additions and 1 deletions
|
@ -109,7 +109,7 @@ export class Decryption {
|
||||||
|
|
||||||
private async getRoomKey(roomId: string, senderKey: string, sessionId: string, newKeys: IncomingRoomKey[] | undefined, txn: Transaction): Promise<RoomKey | undefined> {
|
private async getRoomKey(roomId: string, senderKey: string, sessionId: string, newKeys: IncomingRoomKey[] | undefined, txn: Transaction): Promise<RoomKey | undefined> {
|
||||||
if (newKeys) {
|
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)) {
|
if (key && await key.checkBetterThanKeyInStorage(this.keyLoader, txn)) {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,10 @@ import type {KeyLoader, OlmInboundGroupSession} from "./KeyLoader";
|
||||||
export abstract class RoomKey {
|
export abstract class RoomKey {
|
||||||
private _isBetter: boolean | undefined;
|
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 roomId(): string;
|
||||||
abstract get senderKey(): string;
|
abstract get senderKey(): string;
|
||||||
abstract get sessionId(): string;
|
abstract get sessionId(): string;
|
||||||
|
|
Loading…
Reference in a new issue