Skip to content

Commit fb52e3d

Browse files
authored
Improve the clarity of the unban command (#402)
Also fix a years long bug where the Flooding/Media protection wouldn't stop redacting users Closes #393 Closes #394 * Warn about room level bans when using unban #394 * Clear internal queues within protections when unban happens. #393
1 parent 2c00ac4 commit fb52e3d

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/commands/UnbanBanCommand.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export async function execUnbanCommand(roomId: string, event: any, mjolnir: Mjol
129129

130130
await bits.list!.unbanEntity(bits.ruleType!, bits.entity);
131131

132-
if (USER_RULE_TYPES.includes(bits.ruleType!) && bits.reason === 'true') {
132+
const unbanUserFromRooms = async () => {
133133
const rule = new MatrixGlob(bits.entity);
134134
await mjolnir.managementRoomOutput.logMessage(LogLevel.INFO, "UnbanBanCommand", "Unbanning users that match glob: " + bits.entity);
135135
let unbannedSomeone = false;
@@ -157,6 +157,15 @@ export async function execUnbanCommand(roomId: string, event: any, mjolnir: Mjol
157157
await mjolnir.managementRoomOutput.logMessage(LogLevel.DEBUG, "UnbanBanCommand", `Syncing lists to ensure no users were accidentally unbanned`);
158158
await mjolnir.protectedRoomsTracker.syncLists(mjolnir.config.verboseLogging);
159159
}
160+
};
161+
162+
if (USER_RULE_TYPES.includes(bits.ruleType!)) {
163+
mjolnir.unlistedUserRedactionHandler.removeUser(bits.entity);
164+
if (bits.reason === 'true') {
165+
await unbanUserFromRooms();
166+
} else {
167+
await mjolnir.managementRoomOutput.logMessage(LogLevel.WARN, "UnbanBanCommand", "Running unban without `unban <list> <user> true` will not override existing room level bans");
168+
}
160169
}
161170

162171
await mjolnir.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '✅');

src/queues/UnlistedUserRedactionQueue.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ export class UnlistedUserRedactionQueue {
3333
this.usersToRedact.add(userId);
3434
}
3535

36+
public removeUser(userId: string) {
37+
this.usersToRedact.delete(userId);
38+
}
39+
3640
public isUserQueued(userId: string): boolean {
3741
return this.usersToRedact.has(userId);
3842
}

0 commit comments

Comments
 (0)