Use Self constructors when possible
This commit is contained in:
parent
1a29875fb4
commit
65ef5f21e5
@ -61,7 +61,7 @@ impl OverridePushRule {
|
||||
/// Matches all events, this can be enabled to turn off all push notifications other than those
|
||||
/// generated by override rules set by the user.
|
||||
pub fn master() -> Self {
|
||||
OverridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
actions: vec![DontNotify],
|
||||
default: true,
|
||||
enabled: false,
|
||||
@ -72,7 +72,7 @@ impl OverridePushRule {
|
||||
|
||||
/// Matches messages with a `msgtype` of `notice`.
|
||||
pub fn suppress_notices() -> Self {
|
||||
OverridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
actions: vec![DontNotify],
|
||||
default: true,
|
||||
enabled: true,
|
||||
@ -86,7 +86,7 @@ impl OverridePushRule {
|
||||
|
||||
/// Matches any invites to a new room for this user.
|
||||
pub fn invite_for_me(user_id: &UserId) -> Self {
|
||||
OverridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
actions: vec![
|
||||
Notify,
|
||||
SetTweak(Tweak::Sound("default".into())),
|
||||
@ -105,7 +105,7 @@ impl OverridePushRule {
|
||||
|
||||
/// Matches any `m.room.member_event`.
|
||||
pub fn member_event() -> Self {
|
||||
OverridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
actions: vec![DontNotify],
|
||||
default: true,
|
||||
enabled: true,
|
||||
@ -117,7 +117,7 @@ impl OverridePushRule {
|
||||
/// Matches any message whose content is unencrypted and contains the user's current display
|
||||
/// name in the room in which it was sent.
|
||||
pub fn contains_display_name() -> Self {
|
||||
OverridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
actions: vec![
|
||||
Notify,
|
||||
SetTweak(Tweak::Sound("default".into())),
|
||||
@ -134,7 +134,7 @@ impl OverridePushRule {
|
||||
/// is intended to notify users of a room when it is upgraded,
|
||||
/// similar to what an `@room` notification would accomplish.
|
||||
pub fn tombstone() -> Self {
|
||||
OverridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
actions: vec![Notify, SetTweak(Tweak::Highlight(true))],
|
||||
default: true,
|
||||
enabled: false,
|
||||
@ -149,7 +149,7 @@ impl OverridePushRule {
|
||||
/// Matches any message whose content is unencrypted and contains the text `@room`, signifying
|
||||
/// the whole room should be notified of the event.
|
||||
pub fn roomnotif() -> Self {
|
||||
OverridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
actions: vec![Notify, SetTweak(Tweak::Highlight(true))],
|
||||
default: true,
|
||||
enabled: true,
|
||||
@ -167,7 +167,7 @@ impl ContentPushRule {
|
||||
/// Matches any message whose content is unencrypted and contains the local part of the user's
|
||||
/// Matrix ID, separated by word boundaries.
|
||||
pub fn contains_user_name(user_id: &UserId) -> Self {
|
||||
ContentPushRule(PatternedPushRule {
|
||||
Self(PatternedPushRule {
|
||||
rule_id: ".m.rules.contains_user_name".into(),
|
||||
enabled: true,
|
||||
default: true,
|
||||
@ -185,7 +185,7 @@ impl ContentPushRule {
|
||||
impl UnderridePushRule {
|
||||
/// Matches any incoming VOIP call.
|
||||
pub fn call() -> Self {
|
||||
UnderridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
rule_id: ".m.rules.call".into(),
|
||||
default: true,
|
||||
enabled: true,
|
||||
@ -203,7 +203,7 @@ impl UnderridePushRule {
|
||||
/// encrypted. This causes the rule to be an "all or nothing" match where it either matches all
|
||||
/// events that are encrypted (in 1:1 rooms) or none.
|
||||
pub fn encrypted_room_one_to_one() -> Self {
|
||||
UnderridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
rule_id: ".m.rules.encrypted_room_one_to_one".into(),
|
||||
default: true,
|
||||
enabled: true,
|
||||
@ -221,7 +221,7 @@ impl UnderridePushRule {
|
||||
|
||||
/// Matches any message sent in a room with exactly two members.
|
||||
pub fn room_one_to_one() -> Self {
|
||||
UnderridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
rule_id: ".m.rules.room_one_to_one".into(),
|
||||
default: true,
|
||||
enabled: true,
|
||||
@ -239,7 +239,7 @@ impl UnderridePushRule {
|
||||
|
||||
/// Matches all chat messages.
|
||||
pub fn message() -> Self {
|
||||
UnderridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
rule_id: ".m.rules.message".into(),
|
||||
default: true,
|
||||
enabled: true,
|
||||
@ -253,7 +253,7 @@ impl UnderridePushRule {
|
||||
/// "all or nothing" match where it either matches all events that are encrypted (in group
|
||||
/// rooms) or none.
|
||||
pub fn encrypted() -> Self {
|
||||
UnderridePushRule(ConditionalPushRule {
|
||||
Self(ConditionalPushRule {
|
||||
rule_id: ".m.rules.encrypted".into(),
|
||||
default: true,
|
||||
enabled: true,
|
||||
|
Loading…
x
Reference in New Issue
Block a user