From 5d11114751661dba755fadc289d7c4340d1ab0d0 Mon Sep 17 00:00:00 2001 From: nexy7574 Date: Tue, 7 Jan 2025 00:05:46 +0000 Subject: [PATCH] Remove `--true` flag for `unban` command (#653) Closes #648 by making `--true` the default behaviour. --------- Signed-off-by: nexy7574 --- src/commands/Unban.ts | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/commands/Unban.ts b/src/commands/Unban.ts index e5db7806..c8d087bc 100644 --- a/src/commands/Unban.ts +++ b/src/commands/Unban.ts @@ -101,8 +101,7 @@ export type DraupnirUnbanCommandContext = { }; export const DraupnirUnbanCommand = describeCommand({ - summary: - "Removes an entity from a policy list. If the entity is a glob, then the flag --true must be provided to unban users matching the glob from all protected rooms.", + summary: "Removes an entity from a policy list.", parameters: tuple( { name: "entity", @@ -132,10 +131,14 @@ export const DraupnirUnbanCommand = describeCommand({ }, } ), + // This is a legacy option to unban the user from all rooms that we now ignore just so providing the option doesn't + // cause an error. keywords: { keywordDescriptions: { true: { isFlag: true, + description: + "Legacy, now redundant option to unban the user from all rooms.", }, }, }, @@ -153,7 +156,6 @@ export const DraupnirUnbanCommand = describeCommand({ issuerManager, clientUserID, unlistedUserRedactionQueue, - managementRoomOutput, } = context; const policyRoomReference = typeof policyRoomDesignator === "string" @@ -200,24 +202,11 @@ export const DraupnirUnbanCommand = describeCommand({ } if (typeof entity === "string" || entity instanceof MatrixUserID) { const rawEnttiy = typeof entity === "string" ? entity : entity.toString(); - const isGlob = (string: string) => - string.includes("*") ? true : string.includes("?"); const rule = new MatrixGlob(entity.toString()); if (isStringUserID(rawEnttiy)) { unlistedUserRedactionQueue.removeUser(rawEnttiy); } - if ( - !isGlob(rawEnttiy) || - keywords.getKeywordValue("true", false) - ) { - await unbanUserFromRooms(context, rule); - } else { - await managementRoomOutput.logMessage( - LogLevel.WARN, - "Unban", - "Running unban without `unban true` will not override existing room level bans" - ); - } + await unbanUserFromRooms(context, rule); } return Ok(undefined); },