Actually fix ban command not always applying

Fixes https://github.com/matrix-org/mjolnir/issues/13
This commit is contained in:
Travis Ralston
2019-12-04 19:25:46 -07:00
parent 3be2da5c47
commit 0879cd58a0
2 changed files with 8 additions and 10 deletions
+8 -6
View File
@@ -379,6 +379,14 @@ export class Mjolnir {
}
}
// Check for updated ban lists before checking protected rooms - the ban lists might be protected
// themselves.
if (this.banLists.map(b => b.roomId).includes(roomId)) {
if (ALL_RULE_TYPES.includes(event['type'])) {
await this.syncListForRoom(roomId);
}
}
if (Object.keys(this.protectedRooms).includes(roomId)) {
if (event['sender'] === await this.client.getUserId()) return; // Ignore ourselves
@@ -424,12 +432,6 @@ export class Mjolnir {
await this.printActionResult(errors);
}
}
if (this.banLists.map(b => b.roomId).includes(roomId)) {
if (ALL_RULE_TYPES.includes(event['type'])) {
await this.syncListForRoom(roomId);
}
}
}
private async printActionResult(errors: RoomUpdateError[], title: string = null, logAnyways = false) {
-4
View File
@@ -119,10 +119,6 @@ export async function execBanCommand(roomId: string, event: any, mjolnir: Mjolni
await mjolnir.client.sendStateEvent(bits.list.roomId, bits.ruleType, stateKey, ruleContent);
await mjolnir.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '✅');
// Just sync the lists to apply the ban as it might not always come down /sync for some reason
await logMessage(LogLevel.DEBUG, "UnbanBanCommand", `Syncing lists to ensure the ban is applied`);
await mjolnir.syncLists(config.verboseLogging);
}
// !mjolnir unban <shortcode> <user|server|room> <glob> [apply:t/f]