implement MSC4210, add missing .m.rule.contains_user_name
check
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
d96d981475
commit
39c1addd37
@ -30,6 +30,7 @@ unstable-msc3026 = []
|
|||||||
unstable-msc3930 = []
|
unstable-msc3930 = []
|
||||||
unstable-msc3931 = []
|
unstable-msc3931 = []
|
||||||
unstable-msc3932 = ["unstable-msc3931"]
|
unstable-msc3932 = ["unstable-msc3931"]
|
||||||
|
unstable-msc4210 = []
|
||||||
unstable-unspecified = []
|
unstable-unspecified = []
|
||||||
|
|
||||||
# Allow IDs to exceed 255 bytes.
|
# Allow IDs to exceed 255 bytes.
|
||||||
|
@ -487,6 +487,18 @@ impl ConditionalPushRule {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The old mention rules are disabled when an m.mentions field is present.
|
||||||
|
//
|
||||||
|
// MSC4210 always disables the legacy rules.
|
||||||
|
#[allow(deprecated)]
|
||||||
|
if (self.rule_id == PredefinedOverrideRuleId::RoomNotif.as_ref()
|
||||||
|
|| self.rule_id == PredefinedOverrideRuleId::ContainsDisplayName.as_ref()
|
||||||
|
|| self.rule_id == PredefinedContentRuleId::ContainsUserName.as_ref())
|
||||||
|
&& (event.contains_mentions() || cfg!(feature = "unstable-msc4210"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc3932")]
|
#[cfg(feature = "unstable-msc3932")]
|
||||||
{
|
{
|
||||||
// These 3 rules always apply.
|
// These 3 rules always apply.
|
||||||
@ -510,15 +522,6 @@ impl ConditionalPushRule {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The old mention rules are disabled when an m.mentions field is present.
|
|
||||||
#[allow(deprecated)]
|
|
||||||
if (self.rule_id == PredefinedOverrideRuleId::RoomNotif.as_ref()
|
|
||||||
|| self.rule_id == PredefinedOverrideRuleId::ContainsDisplayName.as_ref())
|
|
||||||
&& event.contains_mentions()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.conditions.iter().all(|cond| cond.applies(event, context))
|
self.conditions.iter().all(|cond| cond.applies(event, context))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ impl Ruleset {
|
|||||||
pub fn server_default(user_id: &UserId) -> Self {
|
pub fn server_default(user_id: &UserId) -> Self {
|
||||||
Self {
|
Self {
|
||||||
content: [
|
content: [
|
||||||
|
#[cfg(not(feature = "unstable-msc4210"))]
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
PatternedPushRule::contains_user_name(user_id),
|
PatternedPushRule::contains_user_name(user_id),
|
||||||
]
|
]
|
||||||
@ -32,9 +33,11 @@ impl Ruleset {
|
|||||||
ConditionalPushRule::invite_for_me(user_id),
|
ConditionalPushRule::invite_for_me(user_id),
|
||||||
ConditionalPushRule::member_event(),
|
ConditionalPushRule::member_event(),
|
||||||
ConditionalPushRule::is_user_mention(user_id),
|
ConditionalPushRule::is_user_mention(user_id),
|
||||||
|
#[cfg(not(feature = "unstable-msc4210"))]
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
ConditionalPushRule::contains_display_name(),
|
ConditionalPushRule::contains_display_name(),
|
||||||
ConditionalPushRule::is_room_mention(),
|
ConditionalPushRule::is_room_mention(),
|
||||||
|
#[cfg(not(feature = "unstable-msc4210"))]
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
ConditionalPushRule::roomnotif(),
|
ConditionalPushRule::roomnotif(),
|
||||||
ConditionalPushRule::tombstone(),
|
ConditionalPushRule::tombstone(),
|
||||||
|
@ -270,6 +270,7 @@ unstable-msc4121 = ["ruma-client-api?/unstable-msc4121"]
|
|||||||
unstable-msc4125 = ["ruma-federation-api?/unstable-msc4125"]
|
unstable-msc4125 = ["ruma-federation-api?/unstable-msc4125"]
|
||||||
unstable-msc4140 = ["ruma-client-api?/unstable-msc4140"]
|
unstable-msc4140 = ["ruma-client-api?/unstable-msc4140"]
|
||||||
unstable-msc4186 = ["ruma-client-api?/unstable-msc4186"]
|
unstable-msc4186 = ["ruma-client-api?/unstable-msc4186"]
|
||||||
|
unstable-msc4210 = ["ruma-common/unstable-msc4210"]
|
||||||
unstable-pdu = ["ruma-events?/unstable-pdu"]
|
unstable-pdu = ["ruma-events?/unstable-pdu"]
|
||||||
unstable-unspecified = [
|
unstable-unspecified = [
|
||||||
"ruma-common/unstable-unspecified",
|
"ruma-common/unstable-unspecified",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user