|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707 |
- // Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
-
- //! Contains the definitions of the "base" push rules.
-
- use std::borrow::Cow;
- use std::collections::HashMap;
-
- use lazy_static::lazy_static;
- use serde_json::Value;
-
- use super::KnownCondition;
- use crate::push::Action;
- use crate::push::Condition;
- use crate::push::EventMatchCondition;
- use crate::push::PushRule;
- use crate::push::RelatedEventMatchCondition;
- use crate::push::SetTweak;
- use crate::push::TweakValue;
-
- const HIGHLIGHT_ACTION: Action = Action::SetTweak(SetTweak {
- set_tweak: Cow::Borrowed("highlight"),
- value: None,
- other_keys: Value::Null,
- });
-
- const HIGHLIGHT_FALSE_ACTION: Action = Action::SetTweak(SetTweak {
- set_tweak: Cow::Borrowed("highlight"),
- value: Some(TweakValue::Other(Value::Bool(false))),
- other_keys: Value::Null,
- });
-
- const SOUND_ACTION: Action = Action::SetTweak(SetTweak {
- set_tweak: Cow::Borrowed("sound"),
- value: Some(TweakValue::String(Cow::Borrowed("default"))),
- other_keys: Value::Null,
- });
-
- const RING_ACTION: Action = Action::SetTweak(SetTweak {
- set_tweak: Cow::Borrowed("sound"),
- value: Some(TweakValue::String(Cow::Borrowed("ring"))),
- other_keys: Value::Null,
- });
-
- pub const BASE_PREPEND_OVERRIDE_RULES: &[PushRule] = &[PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.master"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[]),
- actions: Cow::Borrowed(&[Action::DontNotify]),
- default: true,
- default_enabled: false,
- }];
-
- pub const BASE_APPEND_OVERRIDE_RULES: &[PushRule] = &[
- PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.suppress_notices"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("content.msgtype"),
- pattern: Some(Cow::Borrowed("m.notice")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::DontNotify]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.invite_for_me"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.room.member")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("content.membership"),
- pattern: Some(Cow::Borrowed("invite")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("state_key"),
- pattern: None,
- pattern_type: Some(Cow::Borrowed("user_id")),
- })),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION, SOUND_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.member_event"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.room.member")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::DontNotify]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.im.nheko.msc3664.reply"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::RelatedEventMatch(
- RelatedEventMatchCondition {
- key: Some(Cow::Borrowed("sender")),
- pattern: None,
- pattern_type: Some(Cow::Borrowed("user_id")),
- rel_type: Cow::Borrowed("m.in_reply_to"),
- include_fallbacks: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_ACTION, SOUND_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed(".org.matrix.msc3952.is_user_mentioned"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::IsUserMention)]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_ACTION, SOUND_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.contains_display_name"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::ContainsDisplayName)]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_ACTION, SOUND_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed(".org.matrix.msc3952.is_room_mentioned"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::IsRoomMention),
- Condition::Known(KnownCondition::SenderNotificationPermission {
- key: Cow::Borrowed("room"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_ACTION, SOUND_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.roomnotif"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::SenderNotificationPermission {
- key: Cow::Borrowed("room"),
- }),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("content.body"),
- pattern: Some(Cow::Borrowed("@room")),
- pattern_type: None,
- })),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.tombstone"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.room.tombstone")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("state_key"),
- pattern: Some(Cow::Borrowed("")),
- pattern_type: None,
- })),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.reaction"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.reaction")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::DontNotify]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.m.rule.room.server_acl"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.room.server_acl")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("state_key"),
- pattern: Some(Cow::Borrowed("")),
- pattern_type: None,
- })),
- ]),
- actions: Cow::Borrowed(&[]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/override/.org.matrix.msc3930.rule.poll_response"),
- priority_class: 5,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.response")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[]),
- default: true,
- default_enabled: true,
- },
- ];
-
- pub const BASE_APPEND_CONTENT_RULES: &[PushRule] = &[PushRule {
- rule_id: Cow::Borrowed("global/content/.m.rule.contains_user_name"),
- priority_class: 4,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("content.body"),
- pattern: None,
- pattern_type: Some(Cow::Borrowed("user_localpart")),
- },
- ))]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_ACTION, SOUND_ACTION]),
- default: true,
- default_enabled: true,
- }];
-
- pub const BASE_APPEND_UNDERRIDE_RULES: &[PushRule] = &[
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.m.rule.call"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.call.invite")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::Notify, RING_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.m.rule.room_one_to_one"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.room.message")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.m.rule.encrypted_room_one_to_one"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.room.encrypted")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed(
- "global/underride/.org.matrix.msc3933.rule.extensible.encrypted_room_one_to_one",
- ),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("org.matrix.msc1767.encrypted")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed(
- "global/underride/.org.matrix.msc3933.rule.extensible.message.room_one_to_one",
- ),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("org.matrix.msc1767.message")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed(
- "global/underride/.org.matrix.msc3933.rule.extensible.file.room_one_to_one",
- ),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("org.matrix.msc1767.file")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed(
- "global/underride/.org.matrix.msc3933.rule.extensible.image.room_one_to_one",
- ),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("org.matrix.msc1767.image")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed(
- "global/underride/.org.matrix.msc3933.rule.extensible.video.room_one_to_one",
- ),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("org.matrix.msc1767.video")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed(
- "global/underride/.org.matrix.msc3933.rule.extensible.audio.room_one_to_one",
- ),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("org.matrix.msc1767.audio")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.m.rule.message"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.room.message")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.m.rule.encrypted"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("m.room.encrypted")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc1767.rule.extensible.encrypted"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("m.encrypted")),
- pattern_type: None,
- })),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc1767.rule.extensible.message"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("m.message")),
- pattern_type: None,
- })),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc1767.rule.extensible.file"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("m.file")),
- pattern_type: None,
- })),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc1767.rule.extensible.image"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("m.image")),
- pattern_type: None,
- })),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc1767.rule.extensible.video"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("m.video")),
- pattern_type: None,
- })),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc1767.rule.extensible.audio"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- // MSC3933: Type changed from template rule - see MSC.
- pattern: Some(Cow::Borrowed("m.audio")),
- pattern_type: None,
- })),
- // MSC3933: Add condition on top of template rule - see MSC.
- Condition::Known(KnownCondition::RoomVersionSupports {
- // RoomVersionFeatures::ExtensibleEvents.as_str(), ideally
- feature: Cow::Borrowed("org.matrix.msc3932.extensible_events"),
- }),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.im.vector.jitsi"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("im.vector.modular.widgets")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("content.type"),
- pattern: Some(Cow::Borrowed("jitsi")),
- pattern_type: None,
- })),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("state_key"),
- pattern: Some(Cow::Borrowed("*")),
- pattern_type: None,
- })),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, HIGHLIGHT_FALSE_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_start_one_to_one"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.start")),
- pattern_type: None,
- })),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_start"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.start")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::Notify]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_end_one_to_one"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[
- Condition::Known(KnownCondition::RoomMemberCount {
- is: Some(Cow::Borrowed("2")),
- }),
- Condition::Known(KnownCondition::EventMatch(EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.end")),
- pattern_type: None,
- })),
- ]),
- actions: Cow::Borrowed(&[Action::Notify, SOUND_ACTION]),
- default: true,
- default_enabled: true,
- },
- PushRule {
- rule_id: Cow::Borrowed("global/underride/.org.matrix.msc3930.rule.poll_end"),
- priority_class: 1,
- conditions: Cow::Borrowed(&[Condition::Known(KnownCondition::EventMatch(
- EventMatchCondition {
- key: Cow::Borrowed("type"),
- pattern: Some(Cow::Borrowed("org.matrix.msc3381.poll.end")),
- pattern_type: None,
- },
- ))]),
- actions: Cow::Borrowed(&[Action::Notify]),
- default: true,
- default_enabled: true,
- },
- ];
-
- lazy_static! {
- pub static ref BASE_RULES_BY_ID: HashMap<&'static str, &'static PushRule> =
- BASE_PREPEND_OVERRIDE_RULES
- .iter()
- .chain(BASE_APPEND_OVERRIDE_RULES.iter())
- .chain(BASE_APPEND_CONTENT_RULES.iter())
- .chain(BASE_APPEND_UNDERRIDE_RULES.iter())
- .map(|rule| { (&*rule.rule_id, rule) })
- .collect();
- }
|