Skip to content

Commit fda6581

Browse files
authored
Implement MSC4142: Remove unintentional intentional mentions in replies (#28209)
* Implement MSC4142: Remove unintentional intentional mentions in replies * Fix comment
1 parent 9bfea92 commit fda6581

File tree

3 files changed

+3
-12
lines changed

3 files changed

+3
-12
lines changed

src/components/views/rooms/SendMessageComposer.tsx

+1-8
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,9 @@ export function attachMentions(
9595
const userMentions = new Set<string>();
9696
let roomMention = false;
9797

98-
// If there's a reply, initialize the mentioned users as the sender of that
99-
// event + any mentioned users in that event.
98+
// If there's a reply, initialize the mentioned users as the sender of that event.
10099
if (replyToEvent) {
101100
userMentions.add(replyToEvent.sender!.userId);
102-
// TODO What do we do if the reply event *doeesn't* have this property?
103-
// Try to fish out replies from the contents?
104-
const userIds = replyToEvent.getContent()["m.mentions"]?.user_ids;
105-
if (Array.isArray(userIds)) {
106-
userIds.forEach((userId) => userMentions.add(userId));
107-
}
108101
}
109102

110103
// If user provided content is available, check to see if any users are mentioned.

test/unit-tests/components/views/rooms/EditMessageComposer-test.tsx

-2
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ describe("<EditMessageComposer/>", () => {
432432
user_ids: [
433433
// sender of event we replied to
434434
originalEvent.getSender()!,
435-
// mentions from this event
436-
"@bob:server.org",
437435
],
438436
},
439437
},

test/unit-tests/components/views/rooms/SendMessageComposer-test.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ describe("<SendMessageComposer/>", () => {
194194
"m.mentions": { user_ids: ["@bob:test"] },
195195
});
196196

197-
// It also adds any other mentioned users, but removes yourself.
197+
// It no longer adds any other mentioned users
198198
replyToEvent = mkEvent({
199199
type: "m.room.message",
200200
user: "@bob:test",
@@ -205,7 +205,7 @@ describe("<SendMessageComposer/>", () => {
205205
content = {};
206206
attachMentions("@alice:test", content, model, replyToEvent);
207207
expect(content).toEqual({
208-
"m.mentions": { user_ids: ["@bob:test", "@charlie:test"] },
208+
"m.mentions": { user_ids: ["@bob:test"] },
209209
});
210210
});
211211

0 commit comments

Comments
 (0)