diff --git a/src/protections/MessageIsMedia.ts b/src/protections/MessageIsMedia.ts index bf27aac..791db1a 100644 --- a/src/protections/MessageIsMedia.ts +++ b/src/protections/MessageIsMedia.ts @@ -36,10 +36,13 @@ export class MessageIsMedia extends Protection { public async handleEvent(mjolnir: Mjolnir, roomId: string, event: any): Promise { if (event['type'] === 'm.room.message') { let content = event['content'] || {}; - content = content?.["m.new_content"] ?? content; + const relation = content["m.relates_to"] + if (relation && relation["rel_type"] === "m.replace") { + content = content?.["m.new_content"] ?? content; + } const msgtype = content['msgtype'] || 'm.text'; const formattedBody = content['formatted_body'] || ''; - let isMedia = msgtype === 'm.image' || msgtype === 'm.video' || msgtype === 'm.sticker' || formattedBody.toLowerCase().includes(' new Promise((resolve, reject) => { client.on('room.message', noticeListener(this.mjolnir.managementRoomId, (event) => { if (event.content.body.includes("Redacting event")) { @@ -190,3 +190,4 @@ describe("Test: Protection settings", function() { await reply2; }); }); +