mirror of
https://github.com/the-draupnir-project/Draupnir.git
synced 2026-05-11 01:57:02 +00:00
Actually fix ban command not always applying
Fixes https://github.com/matrix-org/mjolnir/issues/13
This commit is contained in:
+8
-6
@@ -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) {
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user