Skip to content

Commit

Permalink
enhance media protections
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay committed Jul 25, 2024
1 parent 1ffde55 commit a6abe18
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/protections/MessageIsMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ export class MessageIsMedia extends Protection {

public async handleEvent(mjolnir: Mjolnir, roomId: string, event: any): Promise<any> {
if (event['type'] === 'm.room.message') {
const content = event['content'] || {};
let content = event['content'] || {};
content = content?.["m.new_content"] ?? content;
const msgtype = content['msgtype'] || 'm.text';
const formattedBody = content['formatted_body'] || '';
const isMedia = msgtype === 'm.image' || msgtype === 'm.video' || msgtype === 'm.sticker' || formattedBody.toLowerCase().includes('<img');
let isMedia = msgtype === 'm.image' || msgtype === 'm.video' || msgtype === 'm.sticker' || formattedBody.toLowerCase().includes('<img');
if (isMedia) {
await mjolnir.managementRoomOutput.logMessage(LogLevel.WARN, "MessageIsMedia", `Redacting event from ${event['sender']} for posting an image/video. ${Permalinks.forEvent(roomId, event['event_id'], [new UserID(await mjolnir.client.getUserId()).domain])}`);
// Redact the event
Expand Down

0 comments on commit a6abe18

Please sign in to comment.