Skip to content

Conversation

@H-Shay
Copy link
Contributor

@H-Shay H-Shay commented Jul 25, 2024

As the title states.

Fixes #481

@H-Shay H-Shay requested a review from turt2live July 25, 2024 22:26
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise lgtm - thanks!

if (event['type'] === 'm.room.message') {
const content = event['content'] || {};
let content = event['content'] || {};
content = content?.["m.new_content"] ?? content;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably also check m.relates_to to ensure we're actually looking at an edit here. The risk being that someone decides to send partially malformed events to trick Mjolnir into (dis)allowing something which is still rendered to users.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can assume it's an edit if there is both an m.new_content and an m.relates_to field?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

m.relates_to can mean many things, but inspecting it should tell us if it's an edit. In practice this means ensuring the m.relates_to rel_type is m.replace, I think. There's a bunch of validity rules we should probably be checking too, but that might still have false negatives if the code isn't perfect (or someone finds a way to send something weird).

@H-Shay H-Shay requested a review from turt2live July 26, 2024 18:22
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm - thanks!

Co-authored-by: Travis Ralston <travisr@matrix.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: MessageIsMedia does not check m.new_content

3 participants