This commit is contained in:
Will Hunt 2024-09-19 22:33:15 +01:00
parent ec0c8b7484
commit 0c375992ea

View File

@ -72,7 +72,7 @@ export class MentionSpam extends Protection {
public async handleEvent(mjolnir: Mjolnir, roomId: string, event: any): Promise<any> { public async handleEvent(mjolnir: Mjolnir, roomId: string, event: any): Promise<any> {
if (event['type'] === 'm.room.message') { if (event['type'] === 'm.room.message') {
let content = event['content'] || {}; let content = event['content'] || {};
const explicitMentions = content["m.mentions"]?.["m.user_ids"]; const explicitMentions = content["m.mentions"]?.user_ids;
const hitLimit = this.checkMentions(content.body, content.formatted_body, explicitMentions); const hitLimit = this.checkMentions(content.body, content.formatted_body, explicitMentions);
if (hitLimit) { if (hitLimit) {
await mjolnir.managementRoomOutput.logMessage(LogLevel.WARN, "MentionSpam", `Redacting event from ${event['sender']} for spamming mentions. ${Permalinks.forEvent(roomId, event['event_id'], [new UserID(await mjolnir.client.getUserId()).domain])}`); await mjolnir.managementRoomOutput.logMessage(LogLevel.WARN, "MentionSpam", `Redacting event from ${event['sender']} for spamming mentions. ${Permalinks.forEvent(roomId, event['event_id'], [new UserID(await mjolnir.client.getUserId()).domain])}`);