Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
Implement MSC4142: Remove unintentional intentional mentions in replies
Browse files Browse the repository at this point in the history
Signed-off-by: Tulir Asokan <[email protected]>
  • Loading branch information
tulir committed Sep 11, 2024
1 parent 75918f5 commit 37f8503
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
6 changes: 0 additions & 6 deletions src/components/views/rooms/SendMessageComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,6 @@ export function attachMentions(
// event + any mentioned users in that event.
if (replyToEvent) {
userMentions.add(replyToEvent.sender!.userId);
// TODO What do we do if the reply event *doeesn't* have this property?
// Try to fish out replies from the contents?
const userIds = replyToEvent.getContent()["m.mentions"]?.user_ids;
if (Array.isArray(userIds)) {
userIds.forEach((userId) => userMentions.add(userId));
}
}

// If user provided content is available, check to see if any users are mentioned.
Expand Down
2 changes: 0 additions & 2 deletions test/components/views/rooms/EditMessageComposer-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,6 @@ describe("<EditMessageComposer/>", () => {
user_ids: [
// sender of event we replied to
originalEvent.getSender()!,
// mentions from this event
"@bob:server.org",
],
},
},
Expand Down
4 changes: 2 additions & 2 deletions test/components/views/rooms/SendMessageComposer-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ describe("<SendMessageComposer/>", () => {
"m.mentions": { user_ids: ["@bob:test"] },
});

// It also adds any other mentioned users, but removes yourself.
// It no longer adds any other mentioned users
replyToEvent = mkEvent({
type: "m.room.message",
user: "@bob:test",
Expand All @@ -207,7 +207,7 @@ describe("<SendMessageComposer/>", () => {
content = {};
attachMentions("@alice:test", content, model, replyToEvent);
expect(content).toEqual({
"m.mentions": { user_ids: ["@bob:test", "@charlie:test"] },
"m.mentions": { user_ids: ["@bob:test"] },
});
});

Expand Down

0 comments on commit 37f8503

Please sign in to comment.