Skip to content

Commit 746f777

Browse files
authored
Remove null value from message forwarding metadata (#540)
### Description not setting `sender` to `null` anymore but just not setting it. Fixes #539 (hopefully) #### 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 - [ ] 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). no AI was used for this PR
2 parents 7b76e27 + e857201 commit 746f777

2 files changed

Lines changed: 14 additions & 7 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 metadata by removing the `null` value

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ type ForwardMeta = {
9393

9494
// see https://github.com/hummlbach/matrix-doc/blob/acea0854a1c9489599295a858b068ce02a6b2b20/proposals/2723-add-forward-info.md
9595
type MSC2723ForwardMeta = {
96-
event_id: string;
97-
room_id: string;
98-
sender: string | null; // we won't set this field
96+
event_id?: string;
97+
room_id?: string;
98+
sender?: string; // we won't set this field
9999
origin_server_ts: number;
100100
};
101101

@@ -205,9 +205,9 @@ export function MessageForwardInternal({
205205
newBodyPlain = originalBody.length > 0 ? `${bodyModifText}\n\n${quotedBody}` : bodyModifText;
206206

207207
const safeHtml =
208-
originalFormattedBody !== undefined
209-
? sanitizeCustomHtml(originalFormattedBody)
210-
: sanitizeCustomHtml(originalBody).replaceAll('\n', '<br>');
208+
originalFormattedBody === undefined
209+
? sanitizeCustomHtml(originalBody).replaceAll('\n', '<br>')
210+
: sanitizeCustomHtml(originalFormattedBody);
211211

212212
newBodyHtml =
213213
`<div data-forward-marker>` +
@@ -241,6 +241,9 @@ export function MessageForwardInternal({
241241
original_timestamp: mEvent.getTs(),
242242
original_event_private: true,
243243
} satisfies ForwardMeta,
244+
'com.famedly.app.forwarded': {
245+
origin_server_ts: mEvent.getTs(),
246+
} satisfies MSC2723ForwardMeta,
244247
};
245248
} else {
246249
content = {
@@ -261,7 +264,6 @@ export function MessageForwardInternal({
261264
'com.famedly.app.forwarded': {
262265
event_id: eventId,
263266
room_id: room.roomId,
264-
sender: null, // we won't set this field, as a design decision to avoid potential privacy issues and since the sender can be inferred from the event_id and room_id if needed
265267
origin_server_ts: mEvent.getTs(),
266268
} satisfies MSC2723ForwardMeta,
267269
};

0 commit comments

Comments
 (0)