mirror of https://github.com/vector-im/riot-web
Implement MSC4142: Remove unintentional intentional mentions in replies
parent
0c19991e3c
commit
8d654d66ef
|
@ -100,12 +100,6 @@ export function attachMentions(
|
||||||
// event + any mentioned users in that event.
|
// event + any mentioned users in that event.
|
||||||
if (replyToEvent) {
|
if (replyToEvent) {
|
||||||
userMentions.add(replyToEvent.sender!.userId);
|
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.
|
// If user provided content is available, check to see if any users are mentioned.
|
||||||
|
|
|
@ -432,8 +432,6 @@ describe("<EditMessageComposer/>", () => {
|
||||||
user_ids: [
|
user_ids: [
|
||||||
// sender of event we replied to
|
// sender of event we replied to
|
||||||
originalEvent.getSender()!,
|
originalEvent.getSender()!,
|
||||||
// mentions from this event
|
|
||||||
"@bob:server.org",
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -196,7 +196,7 @@ describe("<SendMessageComposer/>", () => {
|
||||||
"m.mentions": { user_ids: ["@bob:test"] },
|
"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({
|
replyToEvent = mkEvent({
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
user: "@bob:test",
|
user: "@bob:test",
|
||||||
|
@ -207,7 +207,7 @@ describe("<SendMessageComposer/>", () => {
|
||||||
content = {};
|
content = {};
|
||||||
attachMentions("@alice:test", content, model, replyToEvent);
|
attachMentions("@alice:test", content, model, replyToEvent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"m.mentions": { user_ids: ["@bob:test", "@charlie:test"] },
|
"m.mentions": { user_ids: ["@bob:test"] },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue