From 0134a637395dac6252f67764f5f51334dbe76065 Mon Sep 17 00:00:00 2001 From: Shay Date: Wed, 22 Jan 2025 16:49:48 -0800 Subject: [PATCH] add some debug logging (#569) --- src/protections/MentionSpam.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/protections/MentionSpam.ts b/src/protections/MentionSpam.ts index 7fdace4b..95a6cb3c 100644 --- a/src/protections/MentionSpam.ts +++ b/src/protections/MentionSpam.ts @@ -16,7 +16,7 @@ limitations under the License. import { Protection } from "./IProtection"; import { Mjolnir } from "../Mjolnir"; -import { LogLevel, Permalinks, UserID } from "@vector-im/matrix-bot-sdk"; +import { LogLevel, LogService, Permalinks, UserID } from "@vector-im/matrix-bot-sdk"; import { NumberProtectionSetting } from "./ProtectionSettings"; import { LRUCache } from "lru-cache"; @@ -106,6 +106,12 @@ export class MentionSpam extends Protection { if (!hitLimit) { const displaynames = await this.getRoomDisplaynames(mjolnir, roomId); hitLimit = this.checkDisplaynameMentions(content.body, content.formatted_body, displaynames); + if (hitLimit) { + LogService.info( + "MentionSpam", + `Hitlimit reached via display name mention check for event content ${JSON.stringify(content)}`, + ); + } } if (hitLimit) { @@ -117,6 +123,10 @@ export class MentionSpam extends Protection { // Redact the event if (!mjolnir.config.noop) { await mjolnir.client.redactEvent(roomId, event["event_id"], "Message was detected as spam."); + LogService.info( + "MentionSpam", + `Redacting event content ${JSON.stringify(content)} for spamming mentions.`, + ); mjolnir.unlistedUserRedactionHandler.addUser(event["sender"]); } else { await mjolnir.managementRoomOutput.logMessage(