Skip to content

Commit

Permalink
Remove --true flag for unban command (#653)
Browse files Browse the repository at this point in the history
Closes #648 by making `--true` the default behaviour.

---------

Signed-off-by: nexy7574 <[email protected]>
  • Loading branch information
nexy7574 authored Jan 7, 2025
1 parent 218d7cd commit 5d11114
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/commands/Unban.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
},
},
},
Expand All @@ -153,7 +156,6 @@ export const DraupnirUnbanCommand = describeCommand({
issuerManager,
clientUserID,
unlistedUserRedactionQueue,
managementRoomOutput,
} = context;
const policyRoomReference =
typeof policyRoomDesignator === "string"
Expand Down Expand Up @@ -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<boolean>("true", false)
) {
await unbanUserFromRooms(context, rule);
} else {
await managementRoomOutput.logMessage(
LogLevel.WARN,
"Unban",
"Running unban without `unban <list> <user> true` will not override existing room level bans"
);
}
await unbanUserFromRooms(context, rule);
}
return Ok(undefined);
},
Expand Down

0 comments on commit 5d11114

Please sign in to comment.