mirror of
https://github.com/matrix-org/mjolnir.git
synced 2024-10-01 01:36:06 -04:00
Support redacting an individual event
This commit is contained in:
parent
1a591b4dcf
commit
e424f03ef2
@ -99,6 +99,7 @@ export async function handleCommand(roomId: string, event: any, mjolnir: Mjolnir
|
||||
"!mjolnir ban <list shortcode> <user|room|server> <glob> [reason] - Adds an entity to the ban list\n" +
|
||||
"!mjolnir unban <list shortcode> <user|room|server> <glob> [apply] - Removes an entity from the ban list. If apply is 'true', the users matching the glob will actually be unbanned\n" +
|
||||
"!mjolnir redact <user ID> [room alias/ID] - Redacts messages by the sender in the target room (or all rooms)\n" +
|
||||
"!mjolnir redact <event permalink> - Redacts a message by permalink\n" +
|
||||
"!mjolnir rules - Lists the rules currently in use by Mjolnir\n" +
|
||||
"!mjolnir sync - Force updates of all lists and re-apply rules\n" +
|
||||
"!mjolnir verify - Ensures Mjolnir can moderate all your rooms\n" +
|
||||
|
@ -16,6 +16,7 @@ limitations under the License.
|
||||
|
||||
import { Mjolnir } from "../Mjolnir";
|
||||
import { redactUserMessagesIn } from "../utils";
|
||||
import { Permalinks } from "matrix-bot-sdk";
|
||||
|
||||
// !mjolnir redact <user ID> [room alias]
|
||||
export async function execRedactCommand(roomId: string, event: any, mjolnir: Mjolnir, parts: string[]) {
|
||||
@ -25,6 +26,15 @@ export async function execRedactCommand(roomId: string, event: any, mjolnir: Mjo
|
||||
roomAlias = await mjolnir.client.resolveRoom(parts[3]);
|
||||
}
|
||||
|
||||
if (userId[0] !== '@') {
|
||||
// Assume it's a permalink
|
||||
const parsed = Permalinks.parseUrl(parts[2]);
|
||||
const targetRoomId = await mjolnir.client.resolveRoom(parsed.roomIdOrAlias);
|
||||
await mjolnir.client.redactEvent(targetRoomId, parsed.eventId);
|
||||
await mjolnir.client.unstableApis.addReactionToEvent(roomId, event['event_id'], '✅');
|
||||
return;
|
||||
}
|
||||
|
||||
const targetRoomIds = roomAlias ? [roomAlias] : Object.keys(mjolnir.protectedRooms);
|
||||
await redactUserMessagesIn(mjolnir.client, userId, targetRoomIds);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user