Skip to content

Recalculate mentions metadata of forwarded messages based on message body#31193

Merged
t3chguy merged 5 commits intoelement-hq:developfrom
twassman:recalculate-mentions-on-forwards
Jan 2, 2026
Merged

Recalculate mentions metadata of forwarded messages based on message body#31193
t3chguy merged 5 commits intoelement-hq:developfrom
twassman:recalculate-mentions-on-forwards

Conversation

@twassman
Copy link
Contributor

@twassman twassman commented Nov 7, 2025

In transformEvent(), parse event body back into an EditorModel, and pass this into attachMentions(), so that it actually recalculates mentions based on the message body.

Follow up to #30884.

Checklist

In transformEvent(), parse event body back into an EditorModel, and pass this into attachMentions(), so that it actually recalculates mentions.
@twassman twassman requested a review from a team as a code owner November 7, 2025 02:54
@twassman twassman changed the title recalculate mentions of forwarded messages Recalculate mentions of forwarded messages Nov 7, 2025
@github-actions github-actions bot added the Z-Community-PR Issue is solved by a community member's PR label Nov 7, 2025
Refactor test for stripping mentions on forwards to allow for more tests of mention recalculation
Fails due to not mocking room membership
@twassman
Copy link
Contributor Author

twassman commented Nov 7, 2025

Tests are pending me figuring out how to correctly mock room membership. In the not-unlikely event that someone knows how to do this, assistance would be welcome.

@florianduros
Copy link
Member

Tests are pending me figuring out how to correctly mock room membership. In the not-unlikely event that someone knows how to do this, assistance would be welcome.

Hi sorry for the delay!

You can use

export function mkMembership(
to create a room membership event.

Or you can also mock the membership of the room with:
jest.spyOn(room, "getMyMembership").mockReturnValue(KnownMembership.Join);

@twassman
Copy link
Contributor Author

Thank you! I'll take a look and see if I can implement this.

@twassman
Copy link
Contributor Author

Apparently all that was necessary was to mock the source room. This should be sufficient?

@t3chguy
Copy link
Member

t3chguy commented Dec 15, 2025

@twassman can you update the PR title to something helpful in a changelog, Recalculate mentions of forwarded messages means nothing to a user

@twassman twassman changed the title Recalculate mentions of forwarded messages Recalculate mentions metadata of forwarded messages based on message body Dec 15, 2025
@twassman
Copy link
Contributor Author

@t3chguy: Better?

@t3chguy
Copy link
Member

t3chguy commented Dec 15, 2025

Not really? What user impact does this have?

@twassman
Copy link
Contributor Author

twassman commented Dec 15, 2025

Ostensibly that the correct set of users would get mentioned when receiving such forwarded messages. I'm not sure exactly what would be preferable for title phrasing.

@twassman
Copy link
Contributor Author

twassman commented Dec 24, 2025

If the PR title is the main issue here, then it would be appreciated if a more suitable title could be provided by someone with a better understanding of what is desired. As this issue most directly deals only with metadata recalculation, I don't know how to phrase this in a more end-user-understandable manner.

@t3chguy t3chguy added this pull request to the merge queue Jan 2, 2026
Merged via the queue into element-hq:develop with commit cbe3eb1 Jan 2, 2026
44 of 47 checks passed
@twassman twassman deleted the recalculate-mentions-on-forwards branch January 2, 2026 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-Defect Z-Community-PR Issue is solved by a community member's PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants