mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 11:35:04 +01:00
rotate outbound megolm session when somebody leaves the room
This commit is contained in:
parent
7da4f5c9ce
commit
d184be2d22
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -134,4 +134,8 @@ export class MemberChange {
|
||||
get membership() {
|
||||
return this._memberEvent.content?.membership;
|
||||
}
|
||||
|
||||
get hasLeft() {
|
||||
return this.previousMembership === "join" && this.membership !== "join";
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ export class OutboundGroupSessionStore {
|
||||
this._store = store;
|
||||
}
|
||||
|
||||
remove(roomId) {
|
||||
this._store.delete(roomId);
|
||||
}
|
||||
|
||||
get(roomId) {
|
||||
return this._store.get(roomId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user