forked from mystiq/hydrogen-web
rotate outbound megolm session when somebody leaves the room
This commit is contained in:
parent
7da4f5c9ce
commit
d184be2d22
4 changed files with 15 additions and 0 deletions
|
@ -45,6 +45,9 @@ export class RoomEncryption {
|
||||||
}
|
}
|
||||||
|
|
||||||
async writeMemberChanges(memberChanges, txn) {
|
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);
|
return await this._deviceTracker.writeMemberChanges(this._room, memberChanges, txn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ export class Encryption {
|
||||||
this._ownDeviceId = ownDeviceId;
|
this._ownDeviceId = ownDeviceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
discardOutboundSession(roomId, txn) {
|
||||||
|
txn.outboundGroupSessions.remove(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encrypts a message with megolm
|
* Encrypts a message with megolm
|
||||||
* @param {string} roomId
|
* @param {string} roomId
|
||||||
|
|
|
@ -134,4 +134,8 @@ export class MemberChange {
|
||||||
get membership() {
|
get membership() {
|
||||||
return this._memberEvent.content?.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;
|
this._store = store;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove(roomId) {
|
||||||
|
this._store.delete(roomId);
|
||||||
|
}
|
||||||
|
|
||||||
get(roomId) {
|
get(roomId) {
|
||||||
return this._store.get(roomId);
|
return this._store.get(roomId);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue