diff --git a/src/@types/PushRules.ts b/src/@types/PushRules.ts index 7b436d85a85..da3b01b6d17 100644 --- a/src/@types/PushRules.ts +++ b/src/@types/PushRules.ts @@ -64,8 +64,6 @@ export enum ConditionKind { EventMatch = "event_match", EventPropertyIs = "event_property_is", EventPropertyContains = "event_property_contains", - IsUserMention = "org.matrix.msc3952.is_user_mention", - IsRoomMention = "org.matrix.msc3952.is_room_mention", ContainsDisplayName = "contains_display_name", RoomMemberCount = "room_member_count", SenderNotificationPermission = "sender_notification_permission", @@ -96,14 +94,6 @@ export interface IEventPropertyContainsCondition extends IPushRuleCondition { - // no additional fields -} - -export interface IIsRoomMentionCondition extends IPushRuleCondition { - // no additional fields -} - export interface IContainsDisplayNameCondition extends IPushRuleCondition { // no additional fields } @@ -131,8 +121,6 @@ export type PushRuleCondition = | IEventMatchCondition | IEventPropertyIsCondition | IEventPropertyContainsCondition - | IIsUserMentionCondition - | IIsRoomMentionCondition | IContainsDisplayNameCondition | IRoomMemberCountCondition | ISenderNotificationPermissionCondition diff --git a/src/pushprocessor.ts b/src/pushprocessor.ts index 9674450b33e..4d85227fe82 100644 --- a/src/pushprocessor.ts +++ b/src/pushprocessor.ts @@ -27,8 +27,6 @@ import { IEventMatchCondition, IEventPropertyIsCondition, IEventPropertyContainsCondition, - IIsRoomMentionCondition, - IIsUserMentionCondition, IPushRule, IPushRules, IRoomMemberCountCondition, @@ -51,8 +49,6 @@ const RULEKINDS_IN_ORDER = [ PushRuleKind.Underride, ]; -const MENTIONS_FIELD = "org.matrix.msc3952.mentions"; - // The default override rules to apply to the push rules that arrive from the server. // We do this for two reasons: // 1. Synapse is unlikely to send us the push rule in an incremental sync - see @@ -391,10 +387,6 @@ export class PushProcessor { return this.eventFulfillsEventPropertyIsCondition(cond, ev); case ConditionKind.EventPropertyContains: return this.eventFulfillsEventPropertyContains(cond, ev); - case ConditionKind.IsUserMention: - return this.eventFulfillsUserMentionCondition(cond, ev); - case ConditionKind.IsRoomMention: - return this.eventFulfillsRoomMentionCondition(cond, ev); case ConditionKind.ContainsDisplayName: return this.eventFulfillsDisplayNameCondition(cond, ev); case ConditionKind.RoomMemberCount: @@ -470,50 +462,6 @@ export class PushProcessor { } } - private eventFulfillsUserMentionCondition(cond: IIsUserMentionCondition, ev: MatrixEvent): boolean { - const content = ev.getContent(); - // Ensure the mentions field exists as an object and contains a user_ids - // field which is an array. - if ( - !content || - !content[MENTIONS_FIELD] || - typeof content[MENTIONS_FIELD] != "object" || - !content[MENTIONS_FIELD].user_ids || - !Array.isArray(content[MENTIONS_FIELD].user_ids) - ) { - return false; - } - - // Ensure the user is still in the room. - // XXX Why do we do this? - const room = this.client.getRoom(ev.getRoomId()); - const userId = this.client.credentials.userId!; - const member = room?.currentState?.getMember(userId); - if (!member) { - return false; - } - - return content[MENTIONS_FIELD].user_ids.includes(userId); - } - - private eventFulfillsRoomMentionCondition(cond: IIsRoomMentionCondition, ev: MatrixEvent): boolean { - const content = ev.getContent(); - // Ensure the mentions field exists as an object and contains a room - // field which is a boolean. - if ( - !content || - !content[MENTIONS_FIELD] || - typeof content[MENTIONS_FIELD] != "object" || - !content[MENTIONS_FIELD].room || - typeof content[MENTIONS_FIELD].user_ids != "boolean" - ) { - return false; - } - - // This must be a boolean, so can just return it directly. - return content[MENTIONS_FIELD].room; - } - private eventFulfillsDisplayNameCondition(cond: IContainsDisplayNameCondition, ev: MatrixEvent): boolean { let content = ev.getContent(); if (ev.isEncrypted() && ev.getClearContent()) {