1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-07-31 15:24:23 +03:00

Stabilize support for MSC3952: intentional mentions (#3397)

* use stable identifiers for MSC3952: intentional mentions

* add matrix version to feature support for intentional mentions
This commit is contained in:
Kerry
2023-07-12 10:04:06 +12:00
committed by GitHub
parent dcf26f3e48
commit 3b88ea19b7
5 changed files with 8 additions and 7 deletions

View File

@ -657,7 +657,7 @@ describe("NotificationService", function () {
content: {
"body": "",
"msgtype": "m.text",
"org.matrix.msc3952.mentions": {},
"m.mentions": {},
},
});

View File

@ -137,8 +137,8 @@ export enum PushRuleKind {
export enum RuleId {
Master = ".m.rule.master",
IsUserMention = ".org.matrix.msc3952.is_user_mention",
IsRoomMention = ".org.matrix.msc3952.is_room_mention",
IsUserMention = ".m.rule.is_user_mention",
IsRoomMention = ".m.rule.is_room_mention",
ContainsDisplayName = ".m.rule.contains_display_name",
ContainsUserName = ".m.rule.contains_user_name",
AtRoomNotification = ".m.rule.roomnotif",

View File

@ -63,6 +63,7 @@ const featureSupportResolver: Record<string, FeatureSupportCondition> = {
},
[Feature.IntentionalMentions]: {
unstablePrefixes: ["org.matrix.msc3952_intentional_mentions"],
matrixVersion: "v1.7",
},
};

View File

@ -57,7 +57,7 @@ export interface IContent {
"displayname"?: string;
"m.relates_to"?: IEventRelation;
"org.matrix.msc3952.mentions"?: IMentions;
"m.mentions"?: IMentions;
}
type StrippedState = Required<Pick<IEvent, "content" | "state_key" | "type" | "sender">>;

View File

@ -78,7 +78,7 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [
conditions: [
{
kind: ConditionKind.EventPropertyContains,
key: "content.org\\.matrix\\.msc3952\\.mentions.user_ids",
key: "content.m\\.mentions.user_ids",
value: "", // The user ID is dynamically added in rewriteDefaultRules.
},
],
@ -91,7 +91,7 @@ const DEFAULT_OVERRIDE_RULES: IPushRule[] = [
conditions: [
{
kind: ConditionKind.EventPropertyIs,
key: "content.org\\.matrix\\.msc3952\\.mentions.room",
key: "content.m\\.mentions.room",
value: true,
},
{
@ -724,7 +724,7 @@ export class PushProcessor {
// Disable the deprecated mentions push rules if the new mentions property exists.
if (
this.client.supportsIntentionalMentions() &&
ev.getContent()["org.matrix.msc3952.mentions"] !== undefined &&
ev.getContent()["m.mentions"] !== undefined &&
(rule.rule_id === RuleId.ContainsUserName ||
rule.rule_id === RuleId.ContainsDisplayName ||
rule.rule_id === RuleId.AtRoomNotification)