1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-09 08:42:50 +03:00

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:
Kerry
2023-07-12 10:29:54 +12:00
committed by GitHub
parent 113b6301f8
commit c5befa1ef8
12 changed files with 88 additions and 85 deletions

View File

@@ -69,7 +69,7 @@ describe("<EditMessageComposer/>", () => {
"format": "org.matrix.custom.html",
"formatted_body":
'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"],
},
},
@@ -303,8 +303,8 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// both content.mentions and new_content.mentions are empty
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({});
expect(messageContent["m.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 () => {
@@ -319,9 +319,9 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// 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
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
user_ids: ["@bob:server.org"],
});
});
@@ -338,9 +338,9 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// 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
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 () => {
@@ -357,10 +357,10 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// new mention in the edit
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({
expect(messageContent["m.mentions"]).toEqual({
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"],
});
});
@@ -380,11 +380,11 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// new mention in the edit
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({
expect(messageContent["m.mentions"]).toEqual({
user_ids: ["@dan:server.org"],
});
// 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"],
});
});
@@ -411,7 +411,7 @@ describe("<EditMessageComposer/>", () => {
event_id: originalEvent.getId(),
},
},
"org.matrix.msc3952.mentions": {
"m.mentions": {
user_ids: [originalEvent.getSender()!],
},
},
@@ -430,7 +430,7 @@ describe("<EditMessageComposer/>", () => {
event_id: originalEvent.getId(),
},
},
"org.matrix.msc3952.mentions": {
"m.mentions": {
user_ids: [
// sender of event we replied to
originalEvent.getSender()!,
@@ -457,9 +457,9 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// 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
expect(messageContent["m.new_content"]["org.matrix.msc3952.mentions"]).toEqual({
expect(messageContent["m.new_content"]["m.mentions"]).toEqual({
user_ids: [originalEvent.getSender()],
});
});
@@ -476,12 +476,12 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// new mention in edit
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({
expect(messageContent["m.mentions"]).toEqual({
user_ids: ["@dan:server.org"],
});
// edited reply still mentions the parent event sender
// 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"],
});
});
@@ -497,10 +497,10 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// no mentions in edit
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
expect(messageContent["m.mentions"]).toEqual({});
// edited reply still mentions the parent event sender
// 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()],
});
});
@@ -518,7 +518,7 @@ describe("<EditMessageComposer/>", () => {
event_id: originalEvent.getId(),
},
},
"org.matrix.msc3952.mentions": {
"m.mentions": {
user_ids: [
// sender of event we replied to
originalEvent.getSender()!,
@@ -537,9 +537,9 @@ describe("<EditMessageComposer/>", () => {
const messageContent = mockClient.sendMessage.mock.calls[0][2];
// no mentions in edit
expect(messageContent["org.matrix.msc3952.mentions"]).toEqual({});
expect(messageContent["m.mentions"]).toEqual({});
// 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()],
});
});