Update to latest ruma/master rev
This commit is contained in:
parent
61458536ab
commit
60381ddcf4
7 changed files with 248 additions and 218 deletions
|
@ -2,47 +2,46 @@ use js_int::uint;
|
|||
use ruma::{
|
||||
identifiers::UserId,
|
||||
push::{
|
||||
Action, ConditionalPushRule, PatternedPushRule, PushCondition, RoomMemberCountIs, Ruleset,
|
||||
Tweak,
|
||||
Action, ConditionalPushRule, ConditionalPushRuleInit, PatternedPushRule,
|
||||
PatternedPushRuleInit, PushCondition, RoomMemberCountIs, Ruleset, Tweak,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn default_pushrules(user_id: &UserId) -> Ruleset {
|
||||
Ruleset {
|
||||
content: vec![contains_user_name_rule(&user_id)],
|
||||
override_: vec![
|
||||
master_rule(),
|
||||
suppress_notices_rule(),
|
||||
invite_for_me_rule(),
|
||||
member_event_rule(),
|
||||
contains_display_name_rule(),
|
||||
tombstone_rule(),
|
||||
roomnotif_rule(),
|
||||
],
|
||||
room: vec![],
|
||||
sender: vec![],
|
||||
underride: vec![
|
||||
call_rule(),
|
||||
encrypted_room_one_to_one_rule(),
|
||||
room_one_to_one_rule(),
|
||||
message_rule(),
|
||||
encrypted_rule(),
|
||||
],
|
||||
}
|
||||
let mut rules = Ruleset::default();
|
||||
rules.content = vec![contains_user_name_rule(&user_id)];
|
||||
rules.override_ = vec![
|
||||
master_rule(),
|
||||
suppress_notices_rule(),
|
||||
invite_for_me_rule(),
|
||||
member_event_rule(),
|
||||
contains_display_name_rule(),
|
||||
tombstone_rule(),
|
||||
roomnotif_rule(),
|
||||
];
|
||||
rules.underride = vec![
|
||||
call_rule(),
|
||||
encrypted_room_one_to_one_rule(),
|
||||
room_one_to_one_rule(),
|
||||
message_rule(),
|
||||
encrypted_rule(),
|
||||
];
|
||||
rules
|
||||
}
|
||||
|
||||
pub fn master_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![Action::DontNotify],
|
||||
default: true,
|
||||
enabled: false,
|
||||
rule_id: ".m.rule.master".to_owned(),
|
||||
conditions: vec![],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn suppress_notices_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![Action::DontNotify],
|
||||
default: true,
|
||||
enabled: true,
|
||||
|
@ -52,10 +51,11 @@ pub fn suppress_notices_rule() -> ConditionalPushRule {
|
|||
pattern: "m.notice".to_owned(),
|
||||
}],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn invite_for_me_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![
|
||||
Action::Notify,
|
||||
Action::SetTweak(Tweak::Sound("default".to_owned())),
|
||||
|
@ -69,10 +69,11 @@ pub fn invite_for_me_rule() -> ConditionalPushRule {
|
|||
pattern: "m.invite".to_owned(),
|
||||
}],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn member_event_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![Action::DontNotify],
|
||||
default: true,
|
||||
enabled: true,
|
||||
|
@ -82,10 +83,11 @@ pub fn member_event_rule() -> ConditionalPushRule {
|
|||
pattern: "type".to_owned(),
|
||||
}],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn contains_display_name_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![
|
||||
Action::Notify,
|
||||
Action::SetTweak(Tweak::Sound("default".to_owned())),
|
||||
|
@ -96,10 +98,11 @@ pub fn contains_display_name_rule() -> ConditionalPushRule {
|
|||
rule_id: ".m.rule.contains_display_name".to_owned(),
|
||||
conditions: vec![PushCondition::ContainsDisplayName],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn tombstone_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(true))],
|
||||
default: true,
|
||||
enabled: true,
|
||||
|
@ -115,10 +118,11 @@ pub fn tombstone_rule() -> ConditionalPushRule {
|
|||
},
|
||||
],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn roomnotif_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(true))],
|
||||
default: true,
|
||||
enabled: true,
|
||||
|
@ -133,10 +137,11 @@ pub fn roomnotif_rule() -> ConditionalPushRule {
|
|||
},
|
||||
],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn contains_user_name_rule(user_id: &UserId) -> PatternedPushRule {
|
||||
PatternedPushRule {
|
||||
PatternedPushRuleInit {
|
||||
actions: vec![
|
||||
Action::Notify,
|
||||
Action::SetTweak(Tweak::Sound("default".to_owned())),
|
||||
|
@ -147,10 +152,11 @@ pub fn contains_user_name_rule(user_id: &UserId) -> PatternedPushRule {
|
|||
rule_id: ".m.rule.contains_user_name".to_owned(),
|
||||
pattern: user_id.localpart().to_owned(),
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn call_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![
|
||||
Action::Notify,
|
||||
Action::SetTweak(Tweak::Sound("ring".to_owned())),
|
||||
|
@ -164,10 +170,11 @@ pub fn call_rule() -> ConditionalPushRule {
|
|||
pattern: "m.call.invite".to_owned(),
|
||||
}],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn encrypted_room_one_to_one_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![
|
||||
Action::Notify,
|
||||
Action::SetTweak(Tweak::Sound("default".to_owned())),
|
||||
|
@ -186,10 +193,11 @@ pub fn encrypted_room_one_to_one_rule() -> ConditionalPushRule {
|
|||
},
|
||||
],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn room_one_to_one_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![
|
||||
Action::Notify,
|
||||
Action::SetTweak(Tweak::Sound("default".to_owned())),
|
||||
|
@ -208,10 +216,11 @@ pub fn room_one_to_one_rule() -> ConditionalPushRule {
|
|||
},
|
||||
],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn message_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(false))],
|
||||
default: true,
|
||||
enabled: true,
|
||||
|
@ -221,10 +230,11 @@ pub fn message_rule() -> ConditionalPushRule {
|
|||
pattern: "m.room.message".to_owned(),
|
||||
}],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
pub fn encrypted_rule() -> ConditionalPushRule {
|
||||
ConditionalPushRule {
|
||||
ConditionalPushRuleInit {
|
||||
actions: vec![Action::Notify, Action::SetTweak(Tweak::Highlight(false))],
|
||||
default: true,
|
||||
enabled: true,
|
||||
|
@ -234,4 +244,5 @@ pub fn encrypted_rule() -> ConditionalPushRule {
|
|||
pattern: "m.room.encrypted".to_owned(),
|
||||
}],
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue