You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-06 12:02:40 +03:00
Implement MSC3952: intentional mentions (#3092)
* Add experimental push rules. * Update for changes to MSC3952: Use event_property_is and event_property_contains. * Revert custom user/room mention conditions. * Skip legacy rule processing if mentions exist. * Add client option for intentional mentions. * Fix tests. * Test leagcy behavior with intentional mentions. * Handle simple review comments.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as utils from "../test-utils/test-utils";
|
||||
import { IActionsObject, PushProcessor } from "../../src/pushprocessor";
|
||||
import { ConditionKind, EventType, IContent, MatrixClient, MatrixEvent, PushRuleActionName } from "../../src";
|
||||
import { ConditionKind, EventType, IContent, MatrixClient, MatrixEvent, PushRuleActionName, RuleId } from "../../src";
|
||||
|
||||
describe("NotificationService", function () {
|
||||
const testUserId = "@ali:matrix.org";
|
||||
@@ -48,6 +48,7 @@ describe("NotificationService", function () {
|
||||
credentials: {
|
||||
userId: testUserId,
|
||||
},
|
||||
supportsIntentionalMentions: () => true,
|
||||
pushRules: {
|
||||
device: {},
|
||||
global: {
|
||||
@@ -712,6 +713,37 @@ describe("NotificationService", function () {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("test intentional mentions behaviour", () => {
|
||||
it.each([RuleId.ContainsUserName, RuleId.ContainsDisplayName, RuleId.AtRoomNotification])(
|
||||
"Rule %s matches unless intentional mentions are enabled",
|
||||
(ruleId) => {
|
||||
const rule = {
|
||||
rule_id: ruleId,
|
||||
actions: [],
|
||||
conditions: [],
|
||||
default: false,
|
||||
enabled: true,
|
||||
};
|
||||
expect(pushProcessor.ruleMatchesEvent(rule, testEvent)).toBe(true);
|
||||
|
||||
// Add the mentions property to the event and the rule is now disabled.
|
||||
testEvent = utils.mkEvent({
|
||||
type: "m.room.message",
|
||||
room: testRoomId,
|
||||
user: "@alfred:localhost",
|
||||
event: true,
|
||||
content: {
|
||||
"body": "",
|
||||
"msgtype": "m.text",
|
||||
"org.matrix.msc3952.mentions": {},
|
||||
},
|
||||
});
|
||||
|
||||
expect(pushProcessor.ruleMatchesEvent(rule, testEvent)).toBe(false);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Test PushProcessor.partsForDottedKey", function () {
|
||||
|
Reference in New Issue
Block a user