Skip to content

Commit f0ad4f5

Browse files
authored
Fix message forwarding by removing relation to avoid issues (#558)
### Description This pull request fixes an issue with forwarding messages for users on Synapse homeservers by ensuring that relations and mentions are properly removed from forwarded messages. The changes focus on improving privacy and preventing confusion when messages are forwarded to other rooms. #### Forwarding and privacy improvements - Removed the `m.relates_to` and `m.mentions` fields from the forwarded message content to avoid leaking relations or mentions from the original message. - Removed the addition of a new `m.relates_to` relation when constructing the forwarded message, preventing references to the original event in the forwarded message. Fixes #539 #### Type of change - [x] Bug fix (non-breaking change which fixes an issue) - [ ] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] This change requires a documentation update ### Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings ### AI disclosure: - [ ] Partially AI assisted (clarify which code was AI assisted and briefly explain what it does). - [ ] Fully AI generated (explain what all the generated code does in moderate detail). <!-- Write any explanation required here, but do not generate the explanation using AI!! You must prove you understand what the code in this PR does. --> no AI was used in the creation of this PR
2 parents f401f07 + 9c61f4c commit f0ad4f5

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
fix forwarding issue for users on synapse homeservers, by removing the relation

src/app/components/message/modals/MessageForward.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,8 @@ export function MessageForwardInternal({
224224
}
225225
: {};
226226
const baseContent = { ...mEvent.getContent() };
227+
delete baseContent['m.relates_to']; // remove relations from the forwarded message
228+
delete baseContent['m.mentions']; // remove mentions from forwarded message
227229
delete baseContent['com.beeper.per_message_profile']; // remove per-message profile as that could confuse clients in the target room
228230
let content;
229231
// handle privacy stuff
@@ -232,8 +234,6 @@ export function MessageForwardInternal({
232234
// we can still include the original message content in the body of the message, so we'll just use a fallback text/plain content with the original message body
233235
content = {
234236
...baseContent,
235-
'm.relates_to': null, // remove any relations to avoid confusion in the target room
236-
'm.mentions': null, // remove mentions to avoid leaking information about users in the original room
237237
...forwardedTextContent,
238238
'moe.sable.message.forward': {
239239
v: 1,
@@ -249,10 +249,6 @@ export function MessageForwardInternal({
249249
content = {
250250
...baseContent,
251251
...forwardedTextContent,
252-
'm.relates_to': {
253-
rel_type: 'm.reference',
254-
event_id: eventId,
255-
},
256252
'moe.sable.message.forward': {
257253
v: 1,
258254
is_forwarded: true,

0 commit comments

Comments
 (0)