Stabilize support for MSC3952: intentional mentions (#10967)
* enable feature_intentional_mentions with v1.7 * org.matrix.msc3952.mentions -> m.mentions * update push rules test util * only support stable version 1.7 * use stable values for msc3952 push rules * use stable intentional mentions rule sin test models * unstable feature in settings controller
This commit is contained in:
parent
113b6301f8
commit
c5befa1ef8
12 changed files with 88 additions and 85 deletions
|
@ -89,7 +89,7 @@ export function attachMentions(
|
||||||
}
|
}
|
||||||
|
|
||||||
// The mentions property *always* gets included to disable legacy push rules.
|
// The mentions property *always* gets included to disable legacy push rules.
|
||||||
const mentions: IMentions = (content["org.matrix.msc3952.mentions"] = {});
|
const mentions: IMentions = (content["m.mentions"] = {});
|
||||||
|
|
||||||
const userMentions = new Set<string>();
|
const userMentions = new Set<string>();
|
||||||
let roomMention = false;
|
let roomMention = false;
|
||||||
|
@ -100,7 +100,7 @@ export function attachMentions(
|
||||||
userMentions.add(replyToEvent.sender!.userId);
|
userMentions.add(replyToEvent.sender!.userId);
|
||||||
// TODO What do we do if the reply event *doeesn't* have this property?
|
// TODO What do we do if the reply event *doeesn't* have this property?
|
||||||
// Try to fish out replies from the contents?
|
// Try to fish out replies from the contents?
|
||||||
const userIds = replyToEvent.getContent()["org.matrix.msc3952.mentions"]?.user_ids;
|
const userIds = replyToEvent.getContent()["m.mentions"]?.user_ids;
|
||||||
if (Array.isArray(userIds)) {
|
if (Array.isArray(userIds)) {
|
||||||
userIds.forEach((userId) => userMentions.add(userId));
|
userIds.forEach((userId) => userMentions.add(userId));
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ export function attachMentions(
|
||||||
if (editedContent) {
|
if (editedContent) {
|
||||||
// First, the new event content gets the *full* set of users.
|
// First, the new event content gets the *full* set of users.
|
||||||
const newContent = content["m.new_content"];
|
const newContent = content["m.new_content"];
|
||||||
const newMentions: IMentions = (newContent["org.matrix.msc3952.mentions"] = {});
|
const newMentions: IMentions = (newContent["m.mentions"] = {});
|
||||||
|
|
||||||
// Only include the users/room if there is any content.
|
// Only include the users/room if there is any content.
|
||||||
if (userMentions.size) {
|
if (userMentions.size) {
|
||||||
|
@ -139,7 +139,7 @@ export function attachMentions(
|
||||||
|
|
||||||
// Fetch the mentions from the original event and remove any previously
|
// Fetch the mentions from the original event and remove any previously
|
||||||
// mentioned users.
|
// mentioned users.
|
||||||
const prevMentions = editedContent["org.matrix.msc3952.mentions"];
|
const prevMentions = editedContent["m.mentions"];
|
||||||
if (Array.isArray(prevMentions?.user_ids)) {
|
if (Array.isArray(prevMentions?.user_ids)) {
|
||||||
prevMentions!.user_ids.forEach((userId) => userMentions.delete(userId));
|
prevMentions!.user_ids.forEach((userId) => userMentions.delete(userId));
|
||||||
}
|
}
|
||||||
|
|
|
@ -552,9 +552,12 @@ export const SETTINGS: { [setting: string]: ISetting } = {
|
||||||
displayName: _td("Enable intentional mentions"),
|
displayName: _td("Enable intentional mentions"),
|
||||||
labsGroup: LabGroup.Rooms,
|
labsGroup: LabGroup.Rooms,
|
||||||
default: false,
|
default: false,
|
||||||
controller: new ServerSupportUnstableFeatureController("feature_intentional_mentions", defaultWatchManager, [
|
controller: new ServerSupportUnstableFeatureController(
|
||||||
["org.matrix.msc3952_intentional_mentions"],
|
"feature_intentional_mentions",
|
||||||
]),
|
defaultWatchManager,
|
||||||
|
[["org.matrix.msc3952_intentional_mentions"]],
|
||||||
|
"v1.7",
|
||||||
|
),
|
||||||
},
|
},
|
||||||
"feature_ask_to_join": {
|
"feature_ask_to_join": {
|
||||||
default: false,
|
default: false,
|
||||||
|
|
|
@ -245,7 +245,7 @@ describe("ContentMessages", () => {
|
||||||
expect.objectContaining({
|
expect.objectContaining({
|
||||||
"url": "mxc://server/file",
|
"url": "mxc://server/file",
|
||||||
"msgtype": "m.image",
|
"msgtype": "m.image",
|
||||||
"org.matrix.msc3952.mentions": {
|
"m.mentions": {
|
||||||
user_ids: ["@bob:test"],
|
user_ids: ["@bob:test"],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -69,7 +69,7 @@ describe("<EditMessageComposer/>", () => {
|
||||||
"format": "org.matrix.custom.html",
|
"format": "org.matrix.custom.html",
|
||||||
"formatted_body":
|
"formatted_body":
|
||||||
'hey <a href="https://matrix.to/#/@bob:server.org">Bob</a> and <a href="https://matrix.to/#/@charlie:server.org">Charlie</a>',
|
'hey <a href="https://matrix.to/#/@bob:server.org">Bob</a> and <a href="https://matrix.to/#/@charlie:server.org">Charlie</a>',
|
||||||
"org.matrix.msc3952.mentions": {
|
"m.mentions": {
|
||||||
user_ids: ["@bob:server.org", "@charlie:server.org"],
|
user_ids: ["@bob:server.org", "@charlie:server.org"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -303,8 +303,8 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// both content.mentions and new_content.mentions are empty
|
// both content.mentions and new_content.mentions are empty
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
|
expect(messageContent["m.mentions"]).toEqual({});
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({});
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should retain mentions in the original message that are not removed by the edit", async () => {
|
it("should retain mentions in the original message that are not removed by the edit", async () => {
|
||||||
|
@ -319,9 +319,9 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// no new mentions were added, so nothing in top level mentions
|
// no new mentions were added, so nothing in top level mentions
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
|
expect(messageContent["m.mentions"]).toEqual({});
|
||||||
// bob is still mentioned, charlie removed
|
// bob is still mentioned, charlie removed
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
|
||||||
user_ids: ["@bob:server.org"],
|
user_ids: ["@bob:server.org"],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -338,9 +338,9 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// no new mentions were added, so nothing in top level mentions
|
// no new mentions were added, so nothing in top level mentions
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
|
expect(messageContent["m.mentions"]).toEqual({});
|
||||||
// bob is not longer mentioned in the edited message, so empty mentions in new_content
|
// bob is not longer mentioned in the edited message, so empty mentions in new_content
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({});
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should add mentions that were added in the edit", async () => {
|
it("should add mentions that were added in the edit", async () => {
|
||||||
|
@ -357,10 +357,10 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// new mention in the edit
|
// new mention in the edit
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.mentions"]).toEqual({
|
||||||
user_ids: ["@dan:server.org"],
|
user_ids: ["@dan:server.org"],
|
||||||
});
|
});
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
|
||||||
user_ids: ["@dan:server.org"],
|
user_ids: ["@dan:server.org"],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -380,11 +380,11 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// new mention in the edit
|
// new mention in the edit
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.mentions"]).toEqual({
|
||||||
user_ids: ["@dan:server.org"],
|
user_ids: ["@dan:server.org"],
|
||||||
});
|
});
|
||||||
// all mentions in the edited version of the event
|
// all mentions in the edited version of the event
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
|
||||||
user_ids: ["@bob:server.org", "@dan:server.org"],
|
user_ids: ["@bob:server.org", "@dan:server.org"],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -411,7 +411,7 @@ describe("<EditMessageComposer/>", () => {
|
||||||
event_id: originalEvent.getId(),
|
event_id: originalEvent.getId(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"org.matrix.msc3952.mentions": {
|
"m.mentions": {
|
||||||
user_ids: [originalEvent.getSender()!],
|
user_ids: [originalEvent.getSender()!],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -430,7 +430,7 @@ describe("<EditMessageComposer/>", () => {
|
||||||
event_id: originalEvent.getId(),
|
event_id: originalEvent.getId(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"org.matrix.msc3952.mentions": {
|
"m.mentions": {
|
||||||
user_ids: [
|
user_ids: [
|
||||||
// sender of event we replied to
|
// sender of event we replied to
|
||||||
originalEvent.getSender()!,
|
originalEvent.getSender()!,
|
||||||
|
@ -457,9 +457,9 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// no new mentions from edit
|
// no new mentions from edit
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
|
expect(messageContent["m.mentions"]).toEqual({});
|
||||||
// edited reply still mentions the parent event sender
|
// edited reply still mentions the parent event sender
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
|
||||||
user_ids: [originalEvent.getSender()],
|
user_ids: [originalEvent.getSender()],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -476,12 +476,12 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// new mention in edit
|
// new mention in edit
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.mentions"]).toEqual({
|
||||||
user_ids: ["@dan:server.org"],
|
user_ids: ["@dan:server.org"],
|
||||||
});
|
});
|
||||||
// edited reply still mentions the parent event sender
|
// edited reply still mentions the parent event sender
|
||||||
// plus new mention @dan
|
// plus new mention @dan
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
|
||||||
user_ids: [originalEvent.getSender(), "@dan:server.org"],
|
user_ids: [originalEvent.getSender(), "@dan:server.org"],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -497,10 +497,10 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// no mentions in edit
|
// no mentions in edit
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
|
expect(messageContent["m.mentions"]).toEqual({});
|
||||||
// edited reply still mentions the parent event sender
|
// edited reply still mentions the parent event sender
|
||||||
// existing @bob mention removed
|
// existing @bob mention removed
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
|
||||||
user_ids: [originalEvent.getSender()],
|
user_ids: [originalEvent.getSender()],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -518,7 +518,7 @@ describe("<EditMessageComposer/>", () => {
|
||||||
event_id: originalEvent.getId(),
|
event_id: originalEvent.getId(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"org.matrix.msc3952.mentions": {
|
"m.mentions": {
|
||||||
user_ids: [
|
user_ids: [
|
||||||
// sender of event we replied to
|
// sender of event we replied to
|
||||||
originalEvent.getSender()!,
|
originalEvent.getSender()!,
|
||||||
|
@ -537,9 +537,9 @@ describe("<EditMessageComposer/>", () => {
|
||||||
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
const messageContent = mockClient.sendMessage.mock.calls[0][2];
|
||||||
|
|
||||||
// no mentions in edit
|
// no mentions in edit
|
||||||
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
|
expect(messageContent["m.mentions"]).toEqual({});
|
||||||
// edited reply still mentions the parent event sender
|
// edited reply still mentions the parent event sender
|
||||||
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
|
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
|
||||||
user_ids: [originalEvent.getSender()],
|
user_ids: [originalEvent.getSender()],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -178,7 +178,7 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const content: IContent = {};
|
const content: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, undefined);
|
attachMentions("@alice:test", content, model, undefined);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const content: IContent = {};
|
const content: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, undefined);
|
attachMentions("@alice:test", content, model, undefined);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": { user_ids: ["@bob:test"] },
|
"m.mentions": { user_ids: ["@bob:test"] },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -198,13 +198,13 @@ describe("<SendMessageComposer/>", () => {
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
user: "@bob:test",
|
user: "@bob:test",
|
||||||
room: "!abc:test",
|
room: "!abc:test",
|
||||||
content: { "org.matrix.msc3952.mentions": {} },
|
content: { "m.mentions": {} },
|
||||||
event: true,
|
event: true,
|
||||||
});
|
});
|
||||||
let content: IContent = {};
|
let content: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, replyToEvent);
|
attachMentions("@alice:test", content, model, replyToEvent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": { user_ids: ["@bob:test"] },
|
"m.mentions": { user_ids: ["@bob:test"] },
|
||||||
});
|
});
|
||||||
|
|
||||||
// It also adds any other mentioned users, but removes yourself.
|
// It also adds any other mentioned users, but removes yourself.
|
||||||
|
@ -212,13 +212,13 @@ describe("<SendMessageComposer/>", () => {
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
user: "@bob:test",
|
user: "@bob:test",
|
||||||
room: "!abc:test",
|
room: "!abc:test",
|
||||||
content: { "org.matrix.msc3952.mentions": { user_ids: ["@alice:test", "@charlie:test"] } },
|
content: { "m.mentions": { user_ids: ["@alice:test", "@charlie:test"] } },
|
||||||
event: true,
|
event: true,
|
||||||
});
|
});
|
||||||
content = {};
|
content = {};
|
||||||
attachMentions("@alice:test", content, model, replyToEvent);
|
attachMentions("@alice:test", content, model, replyToEvent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": { user_ids: ["@bob:test", "@charlie:test"] },
|
"m.mentions": { user_ids: ["@bob:test", "@charlie:test"] },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const content: IContent = {};
|
const content: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, undefined);
|
attachMentions("@alice:test", content, model, undefined);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": { room: true },
|
"m.mentions": { room: true },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -238,13 +238,13 @@ describe("<SendMessageComposer/>", () => {
|
||||||
type: "m.room.message",
|
type: "m.room.message",
|
||||||
user: "@alice:test",
|
user: "@alice:test",
|
||||||
room: "!abc:test",
|
room: "!abc:test",
|
||||||
content: { "org.matrix.msc3952.mentions": { room: true } },
|
content: { "m.mentions": { room: true } },
|
||||||
event: true,
|
event: true,
|
||||||
});
|
});
|
||||||
const content: IContent = {};
|
const content: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, replyToEvent);
|
attachMentions("@alice:test", content, model, replyToEvent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -256,13 +256,13 @@ describe("<SendMessageComposer/>", () => {
|
||||||
user: "@alice:test",
|
user: "@alice:test",
|
||||||
room: "!abc:test",
|
room: "!abc:test",
|
||||||
// @ts-ignore - Purposefully testing invalid data.
|
// @ts-ignore - Purposefully testing invalid data.
|
||||||
content: { "org.matrix.msc3952.mentions": { user_ids: "@bob:test" } },
|
content: { "m.mentions": { user_ids: "@bob:test" } },
|
||||||
event: true,
|
event: true,
|
||||||
});
|
});
|
||||||
const content: IContent = {};
|
const content: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, replyToEvent);
|
attachMentions("@alice:test", content, model, replyToEvent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -273,8 +273,8 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const prevContent: IContent = {};
|
const prevContent: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, undefined, prevContent);
|
attachMentions("@alice:test", content, model, undefined, prevContent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
"m.new_content": { "org.matrix.msc3952.mentions": {} },
|
"m.new_content": { "m.mentions": {} },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -282,12 +282,12 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const model = new EditorModel([], partsCreator);
|
const model = new EditorModel([], partsCreator);
|
||||||
const content: IContent = { "m.new_content": {} };
|
const content: IContent = { "m.new_content": {} };
|
||||||
const prevContent: IContent = {
|
const prevContent: IContent = {
|
||||||
"org.matrix.msc3952.mentions": { user_ids: ["@bob:test"], room: true },
|
"m.mentions": { user_ids: ["@bob:test"], room: true },
|
||||||
};
|
};
|
||||||
attachMentions("@alice:test", content, model, undefined, prevContent);
|
attachMentions("@alice:test", content, model, undefined, prevContent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
"m.new_content": { "org.matrix.msc3952.mentions": {} },
|
"m.new_content": { "m.mentions": {} },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -297,19 +297,19 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const prevContent: IContent = {};
|
const prevContent: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, undefined, prevContent);
|
attachMentions("@alice:test", content, model, undefined, prevContent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": { user_ids: ["@bob:test"] },
|
"m.mentions": { user_ids: ["@bob:test"] },
|
||||||
"m.new_content": { "org.matrix.msc3952.mentions": { user_ids: ["@bob:test"] } },
|
"m.new_content": { "m.mentions": { user_ids: ["@bob:test"] } },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("test prev user mentions", () => {
|
it("test prev user mentions", () => {
|
||||||
const model = new EditorModel([partsCreator.userPill("Bob", "@bob:test")], partsCreator);
|
const model = new EditorModel([partsCreator.userPill("Bob", "@bob:test")], partsCreator);
|
||||||
const content: IContent = { "m.new_content": {} };
|
const content: IContent = { "m.new_content": {} };
|
||||||
const prevContent: IContent = { "org.matrix.msc3952.mentions": { user_ids: ["@bob:test"] } };
|
const prevContent: IContent = { "m.mentions": { user_ids: ["@bob:test"] } };
|
||||||
attachMentions("@alice:test", content, model, undefined, prevContent);
|
attachMentions("@alice:test", content, model, undefined, prevContent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
"m.new_content": { "org.matrix.msc3952.mentions": { user_ids: ["@bob:test"] } },
|
"m.new_content": { "m.mentions": { user_ids: ["@bob:test"] } },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -319,19 +319,19 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const prevContent: IContent = {};
|
const prevContent: IContent = {};
|
||||||
attachMentions("@alice:test", content, model, undefined, prevContent);
|
attachMentions("@alice:test", content, model, undefined, prevContent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": { room: true },
|
"m.mentions": { room: true },
|
||||||
"m.new_content": { "org.matrix.msc3952.mentions": { room: true } },
|
"m.new_content": { "m.mentions": { room: true } },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("test prev room mention", () => {
|
it("test prev room mention", () => {
|
||||||
const model = new EditorModel([partsCreator.atRoomPill("@room")], partsCreator);
|
const model = new EditorModel([partsCreator.atRoomPill("@room")], partsCreator);
|
||||||
const content: IContent = { "m.new_content": {} };
|
const content: IContent = { "m.new_content": {} };
|
||||||
const prevContent: IContent = { "org.matrix.msc3952.mentions": { room: true } };
|
const prevContent: IContent = { "m.mentions": { room: true } };
|
||||||
attachMentions("@alice:test", content, model, undefined, prevContent);
|
attachMentions("@alice:test", content, model, undefined, prevContent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
"m.new_content": { "org.matrix.msc3952.mentions": { room: true } },
|
"m.new_content": { "m.mentions": { room: true } },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -340,11 +340,11 @@ describe("<SendMessageComposer/>", () => {
|
||||||
const model = new EditorModel([], partsCreator);
|
const model = new EditorModel([], partsCreator);
|
||||||
const content: IContent = { "m.new_content": {} };
|
const content: IContent = { "m.new_content": {} };
|
||||||
// @ts-ignore - Purposefully testing invalid data.
|
// @ts-ignore - Purposefully testing invalid data.
|
||||||
const prevContent: IContent = { "org.matrix.msc3952.mentions": { user_ids: "@bob:test" } };
|
const prevContent: IContent = { "m.mentions": { user_ids: "@bob:test" } };
|
||||||
attachMentions("@alice:test", content, model, undefined, prevContent);
|
attachMentions("@alice:test", content, model, undefined, prevContent);
|
||||||
expect(content).toEqual({
|
expect(content).toEqual({
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
"m.new_content": { "org.matrix.msc3952.mentions": {} },
|
"m.new_content": { "m.mentions": {} },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -135,7 +135,7 @@ describe("<VoiceRecordComposerTile/>", () => {
|
||||||
"org.matrix.msc1767.text": "Voice message",
|
"org.matrix.msc1767.text": "Voice message",
|
||||||
"org.matrix.msc3245.voice": {},
|
"org.matrix.msc3245.voice": {},
|
||||||
"url": "mxc://example.com/voice",
|
"url": "mxc://example.com/voice",
|
||||||
"org.matrix.msc3952.mentions": {},
|
"m.mentions": {},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ describe("<VoiceRecordComposerTile/>", () => {
|
||||||
event_id: replyToEvent.getId(),
|
event_id: replyToEvent.getId(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"org.matrix.msc3952.mentions": { user_ids: ["@bob:test"] },
|
"m.mentions": { user_ids: ["@bob:test"] },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -345,13 +345,13 @@
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule_id": ".org.matrix.msc3952.is_user_mention",
|
"rule_id": ".m.rule.is_user_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_contains",
|
"kind": "event_property_contains",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
"key": "content.m\\.mentions.user_ids",
|
||||||
"value": "@jannemk:element.io"
|
"value": "@jannemk:element.io"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -363,13 +363,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule_id": ".org.matrix.msc3952.is_room_mention",
|
"rule_id": ".m.rule.is_room_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_is",
|
"kind": "event_property_is",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.room",
|
"key": "content.m\\.mentions.room",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -315,13 +315,13 @@
|
||||||
"enabled": true
|
"enabled": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule_id": ".org.matrix.msc3952.is_user_mention",
|
"rule_id": ".m.rule.is_user_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": false,
|
"enabled": false,
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_contains",
|
"kind": "event_property_contains",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
"key": "content.m\\.mentions.user_ids",
|
||||||
"value": "@jannemk:element.io"
|
"value": "@jannemk:element.io"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -333,13 +333,13 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule_id": ".org.matrix.msc3952.is_room_mention",
|
"rule_id": ".m.rule.is_room_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_is",
|
"kind": "event_property_is",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.room",
|
"key": "content.m\\.mentions.room",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -259,7 +259,7 @@
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_contains",
|
"kind": "event_property_contains",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
"key": "content.m\\.mentions.user_ids",
|
||||||
"value": "@jannetestuser:beta.matrix.org"
|
"value": "@jannetestuser:beta.matrix.org"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -269,7 +269,7 @@
|
||||||
"set_tweak": "highlight"
|
"set_tweak": "highlight"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rule_id": ".org.matrix.msc3952.is_user_mention",
|
"rule_id": ".m.rule.is_user_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"kind": "override"
|
"kind": "override"
|
||||||
|
@ -299,7 +299,7 @@
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_is",
|
"kind": "event_property_is",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.room",
|
"key": "content.m\\.mentions.room",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -313,7 +313,7 @@
|
||||||
"set_tweak": "highlight"
|
"set_tweak": "highlight"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rule_id": ".org.matrix.msc3952.is_room_mention",
|
"rule_id": ".m.rule.is_room_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"kind": "override"
|
"kind": "override"
|
||||||
|
|
|
@ -265,7 +265,7 @@
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_contains",
|
"kind": "event_property_contains",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
"key": "content.m\\.mentions.user_ids",
|
||||||
"value": "@jannetestuser:beta.matrix.org"
|
"value": "@jannetestuser:beta.matrix.org"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -275,7 +275,7 @@
|
||||||
"set_tweak": "highlight"
|
"set_tweak": "highlight"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rule_id": ".org.matrix.msc3952.is_user_mention",
|
"rule_id": ".m.rule.is_user_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"kind": "override"
|
"kind": "override"
|
||||||
|
@ -305,7 +305,7 @@
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_is",
|
"kind": "event_property_is",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.room",
|
"key": "content.m\\.mentions.room",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -319,7 +319,7 @@
|
||||||
"set_tweak": "highlight"
|
"set_tweak": "highlight"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rule_id": ".org.matrix.msc3952.is_room_mention",
|
"rule_id": ".m.rule.is_room_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"kind": "override"
|
"kind": "override"
|
||||||
|
|
|
@ -501,13 +501,13 @@
|
||||||
"kind": "override"
|
"kind": "override"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule_id": ".org.matrix.msc3952.is_user_mention",
|
"rule_id": ".m.rule.is_user_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_contains",
|
"kind": "event_property_contains",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
"key": "content.m\\.mentions.user_ids",
|
||||||
"value": "@jannemk:element.io"
|
"value": "@jannemk:element.io"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -520,13 +520,13 @@
|
||||||
"kind": "override"
|
"kind": "override"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"rule_id": ".org.matrix.msc3952.is_room_mention",
|
"rule_id": ".m.rule.is_room_mention",
|
||||||
"default": true,
|
"default": true,
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"conditions": [
|
"conditions": [
|
||||||
{
|
{
|
||||||
"kind": "event_property_is",
|
"kind": "event_property_is",
|
||||||
"key": "content.org\\.matrix\\.msc3952\\.mentions.room",
|
"key": "content.m\\.mentions.room",
|
||||||
"value": true
|
"value": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -237,12 +237,12 @@ export const DEFAULT_PUSH_RULES: IPushRules = Object.freeze({
|
||||||
conditions: [
|
conditions: [
|
||||||
{
|
{
|
||||||
kind: "event_property_contains",
|
kind: "event_property_contains",
|
||||||
key: "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
|
key: "content.m\\.mentions.user_ids",
|
||||||
value_type: "user_id",
|
value_type: "user_id",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
actions: ["notify", { set_tweak: "highlight" }, { set_tweak: "sound", value: "default" }],
|
actions: ["notify", { set_tweak: "highlight" }, { set_tweak: "sound", value: "default" }],
|
||||||
rule_id: ".org.matrix.msc3952.is_user_mention",
|
rule_id: ".m.rule.is_user_mention",
|
||||||
default: true,
|
default: true,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
|
@ -255,11 +255,11 @@ export const DEFAULT_PUSH_RULES: IPushRules = Object.freeze({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
conditions: [
|
conditions: [
|
||||||
{ kind: "event_property_is", key: "content.org\\.matrix\\.msc3952\\.mentions.room", value: true },
|
{ kind: "event_property_is", key: "content.m\\.mentions.room", value: true },
|
||||||
{ kind: "sender_notification_permission", key: "room" },
|
{ kind: "sender_notification_permission", key: "room" },
|
||||||
],
|
],
|
||||||
actions: ["notify", { set_tweak: "highlight" }],
|
actions: ["notify", { set_tweak: "highlight" }],
|
||||||
rule_id: ".org.matrix.msc3952.is_room_mention",
|
rule_id: ".m.rule.is_room_mention",
|
||||||
default: true,
|
default: true,
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue