rotate outbound megolm session when somebody leaves the room

This commit is contained in:
Bruno Windels 2020-09-08 11:09:09 +02:00
parent 7da4f5c9ce
commit d184be2d22
4 changed files with 15 additions and 0 deletions

View File

@ -45,6 +45,9 @@ export class RoomEncryption {
}
async writeMemberChanges(memberChanges, txn) {
if (memberChanges.some(m => m.hasLeft)) {
this._megolmEncryption.discardOutboundSession(this._room.id, txn);
}
return await this._deviceTracker.writeMemberChanges(this._room, memberChanges, txn);
}

View File

@ -26,6 +26,10 @@ export class Encryption {
this._ownDeviceId = ownDeviceId;
}
discardOutboundSession(roomId, txn) {
txn.outboundGroupSessions.remove(roomId);
}
/**
* Encrypts a message with megolm
* @param {string} roomId

View File

@ -134,4 +134,8 @@ export class MemberChange {
get membership() {
return this._memberEvent.content?.membership;
}
get hasLeft() {
return this.previousMembership === "join" && this.membership !== "join";
}
}

View File

@ -19,6 +19,10 @@ export class OutboundGroupSessionStore {
this._store = store;
}
remove(roomId) {
this._store.delete(roomId);
}
get(roomId) {
return this._store.get(roomId);
}