mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
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 https://github.com/matrix-org/mjolnir/issues/394 * Clear internal queues within protections when unban happens. https://github.com/matrix-org/mjolnir/issues/393
This commit is contained in:
parent
2c00ac4372
commit
fb52e3dcb2
@ -129,7 +129,7 @@ export async function execUnbanCommand(roomId: string, event: any, mjolnir: Mjol
|
||||
|
||||
await bits.list!.unbanEntity(bits.ruleType!, bits.entity);
|
||||
|
||||
if (USER_RULE_TYPES.includes(bits.ruleType!) && bits.reason === 'true') {
|
||||
const unbanUserFromRooms = async () => {
|
||||
const rule = new MatrixGlob(bits.entity);
|
||||
await mjolnir.managementRoomOutput.logMessage(LogLevel.INFO, "UnbanBanCommand", "Unbanning users that match glob: " + bits.entity);
|
||||
let unbannedSomeone = false;
|
||||
@ -157,6 +157,15 @@ export async function execUnbanCommand(roomId: string, event: any, mjolnir: Mjol
|
||||
await mjolnir.managementRoomOutput.logMessage(LogLevel.DEBUG, "UnbanBanCommand", `Syncing lists to ensure no users were accidentally unbanned`);
|
||||
await mjolnir.protectedRoomsTracker.syncLists(mjolnir.config.verboseLogging);
|
||||
}
|
||||
};
|
||||
|
||||
if (USER_RULE_TYPES.includes(bits.ruleType!)) {
|
||||
mjolnir.unlistedUserRedactionHandler.removeUser(bits.entity);
|
||||
if (bits.reason === 'true') {
|
||||
await unbanUserFromRooms();
|
||||
} else {
|
||||
await mjolnir.managementRoomOutput.logMessage(LogLevel.WARN, "UnbanBanCommand", "Running unban without `unban <list> <user> true` will not override existing room level bans");
|
||||
}
|
||||
}
|
||||
|
||||
await mjolnir.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '✅');
|
||||
|
@ -33,6 +33,10 @@ export class UnlistedUserRedactionQueue {
|
||||
this.usersToRedact.add(userId);
|
||||
}
|
||||
|
||||
public removeUser(userId: string) {
|
||||
this.usersToRedact.delete(userId);
|
||||
}
|
||||
|
||||
public isUserQueued(userId: string): boolean {
|
||||
return this.usersToRedact.has(userId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user