Clear internal queues within protections when unban happens.

https://github.com/matrix-org/mjolnir/issues/393
This commit is contained in:
gnuxie 2022-10-31 17:55:57 +00:00
parent 1c42e1ef7a
commit 93861950ba
2 changed files with 14 additions and 3 deletions

View File

@ -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,8 +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);
}
} else if (USER_RULE_TYPES.includes(bits.ruleType!) && bits.reason === 'false') {
await mjolnir.managementRoomOutput.logMessage(LogLevel.WARN, "UnbanBanCommand", "Running unban without `unban <list> <user> true` will not override existing room level bans");
};
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'], '✅');

View File

@ -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);
}