From 37f8503d0c558b1931ac7440360b9556cd1bc1e7 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Thu, 9 May 2024 19:42:04 +0300 Subject: [PATCH] Implement MSC4142: Remove unintentional intentional mentions in replies Signed-off-by: Tulir Asokan --- src/components/views/rooms/SendMessageComposer.tsx | 6 ------ test/components/views/rooms/EditMessageComposer-test.tsx | 2 -- test/components/views/rooms/SendMessageComposer-test.tsx | 4 ++-- 3 files changed, 2 insertions(+), 10 deletions(-) diff --git a/src/components/views/rooms/SendMessageComposer.tsx b/src/components/views/rooms/SendMessageComposer.tsx index 1b3fb47163..a4e3e5a541 100644 --- a/src/components/views/rooms/SendMessageComposer.tsx +++ b/src/components/views/rooms/SendMessageComposer.tsx @@ -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. diff --git a/test/components/views/rooms/EditMessageComposer-test.tsx b/test/components/views/rooms/EditMessageComposer-test.tsx index 21874ae679..3c17f25852 100644 --- a/test/components/views/rooms/EditMessageComposer-test.tsx +++ b/test/components/views/rooms/EditMessageComposer-test.tsx @@ -432,8 +432,6 @@ describe("", () => { user_ids: [ // sender of event we replied to originalEvent.getSender()!, - // mentions from this event - "@bob:server.org", ], }, }, diff --git a/test/components/views/rooms/SendMessageComposer-test.tsx b/test/components/views/rooms/SendMessageComposer-test.tsx index 11d887bd9d..645d8e0615 100644 --- a/test/components/views/rooms/SendMessageComposer-test.tsx +++ b/test/components/views/rooms/SendMessageComposer-test.tsx @@ -196,7 +196,7 @@ describe("", () => { "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", @@ -207,7 +207,7 @@ describe("", () => { content = {}; attachMentions("@alice:test", content, model, replyToEvent); expect(content).toEqual({ - "m.mentions": { user_ids: ["@bob:test", "@charlie:test"] }, + "m.mentions": { user_ids: ["@bob:test"] }, }); });