-
Notifications
You must be signed in to change notification settings - Fork 63
Description
The mjolnirs will still compare the event against their joined/protected rooms deeper in the chain, so they won't act on any events in rooms they're not joined to or protecting, but this still is problematic and we should have defence in depth.
Lines 533 to 558 in 818e4cf
private async handleEvent(roomId: string, event: any) { | |
// Check for UISI errors | |
if (roomId === this.managementRoomId) { | |
if (event['type'] === 'm.room.message' && event['content'] && event['content']['body']) { | |
if (event['content']['body'] === "** Unable to decrypt: The sender's device has not sent us the keys for this message. **") { | |
// UISI | |
await this.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '⚠'); | |
await this.client.unstableApis.addReactionToEvent(roomId, event['event_id'], 'UISI'); | |
await this.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '🚨'); | |
} | |
} | |
} | |
// Check for updated ban lists before checking protected rooms - the ban lists might be protected | |
// themselves. | |
const policyList = this.policyLists.find(list => list.roomId === roomId); | |
if (policyList !== undefined) { | |
if (ALL_BAN_LIST_RULE_TYPES.includes(event['type']) || event['type'] === 'm.room.redaction') { | |
policyList.updateForEvent(event.event_id) | |
} | |
} | |
if (event.sender !== this.clientUserId) { | |
this.protectedRoomsTracker.handleEvent(roomId, event); | |
} | |
} |
mjolnir/src/ProtectedRoomsSet.ts
Lines 176 to 178 in 818e4cf
if (!this.protectedRooms.has(roomId)) { | |
return; // We're not protecting this room. | |
} |
Inspiration should be taken from bridges on how they manage tracking of rooms. The thing is you shouldn't do this naively because it does duplicate effort. Mjolnir instance already track which rooms they are joined to and are protecting, we just don't have a way to map from a roomId to a set of Mjolnirs that are joined to that room.
mjolnir/src/appservice/MjolnirManager.ts
Lines 99 to 104 in 818e4cf
public onEvent(request: Request<WeakEvent>, context: BridgeContext) { | |
// We honestly don't know how we're going to map from bridge to user | |
// https://github.com/matrix-org/matrix-appservice-bridge/blob/6046d31c54d461ad53e6d6e244ce2d944b62f890/src/components/room-bridge-store.ts | |
// looks like it might work, but we will ask, figure it out later. | |
[...this.mjolnirs.values()].forEach((mj: ManagedMjolnir) => mj.onEvent(request)); | |
} |