push: Stabilize event_property_is
This commit is contained in:
parent
93ae0a3379
commit
b8668f863b
@ -23,7 +23,7 @@ Improvements:
|
|||||||
- Add `InitialStateEvent::{new, to_raw, to_raw_any}`
|
- Add `InitialStateEvent::{new, to_raw, to_raw_any}`
|
||||||
- Add a convenience method to construct `RoomEncryptionEventContent` with the recommended defaults.
|
- Add a convenience method to construct `RoomEncryptionEventContent` with the recommended defaults.
|
||||||
- `PushCondition::EventMatch` and `FlattenedJson` now use escaped dotted paths, according to MSC3873
|
- `PushCondition::EventMatch` and `FlattenedJson` now use escaped dotted paths, according to MSC3873
|
||||||
- Add unstable support for `event_property_is` push condition according to MSC3758
|
- Add support for `event_property_is` push condition (MSC3758 / Matrix 1.7)
|
||||||
- Add unstable support for `event_property_contains` push condition according to MSC3966
|
- Add unstable support for `event_property_contains` push condition according to MSC3966
|
||||||
- Add `FullStateEventContent::redact`
|
- Add `FullStateEventContent::redact`
|
||||||
- Add new methods for `RoomPowerLevels`:
|
- Add new methods for `RoomPowerLevels`:
|
||||||
|
@ -42,7 +42,6 @@ unstable-msc3551 = ["unstable-msc3956"]
|
|||||||
unstable-msc3552 = ["unstable-msc3551"]
|
unstable-msc3552 = ["unstable-msc3551"]
|
||||||
unstable-msc3553 = ["unstable-msc3552"]
|
unstable-msc3553 = ["unstable-msc3552"]
|
||||||
unstable-msc3554 = ["unstable-msc1767"]
|
unstable-msc3554 = ["unstable-msc1767"]
|
||||||
unstable-msc3758 = []
|
|
||||||
unstable-msc3927 = ["unstable-msc3551"]
|
unstable-msc3927 = ["unstable-msc3551"]
|
||||||
unstable-msc3931 = []
|
unstable-msc3931 = []
|
||||||
unstable-msc3932 = ["unstable-msc3931"]
|
unstable-msc3932 = ["unstable-msc3931"]
|
||||||
|
@ -107,12 +107,10 @@ pub enum PushCondition {
|
|||||||
},
|
},
|
||||||
|
|
||||||
/// Exact value match on a property of the event.
|
/// Exact value match on a property of the event.
|
||||||
#[cfg(feature = "unstable-msc3758")]
|
|
||||||
EventPropertyIs {
|
EventPropertyIs {
|
||||||
/// The dot-separated path of the property of the event to match. See [MSC3873] for its
|
/// The [dot-separated path] of the property of the event to match.
|
||||||
/// format.
|
|
||||||
///
|
///
|
||||||
/// [MSC3873]: https://github.com/matrix-org/matrix-spec-proposals/pull/3873
|
/// [dot-separated path]: https://spec.matrix.org/latest/appendices/#dot-separated-property-paths
|
||||||
key: String,
|
key: String,
|
||||||
|
|
||||||
/// The value to match against.
|
/// The value to match against.
|
||||||
@ -202,7 +200,6 @@ impl PushCondition {
|
|||||||
}
|
}
|
||||||
RoomVersionFeature::_Custom(_) => false,
|
RoomVersionFeature::_Custom(_) => false,
|
||||||
},
|
},
|
||||||
#[cfg(feature = "unstable-msc3758")]
|
|
||||||
Self::EventPropertyIs { key, value } => event.get(key).map_or(false, |v| v == value),
|
Self::EventPropertyIs { key, value } => event.get(key).map_or(false, |v| v == value),
|
||||||
#[cfg(feature = "unstable-msc3966")]
|
#[cfg(feature = "unstable-msc3966")]
|
||||||
Self::EventPropertyContains { key, value } => event
|
Self::EventPropertyContains { key, value } => event
|
||||||
@ -805,7 +802,6 @@ mod tests {
|
|||||||
assert!(!room_version_condition.applies(&simple_event, &context_not_matching));
|
assert!(!room_version_condition.applies(&simple_event, &context_not_matching));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc3758")]
|
|
||||||
#[test]
|
#[test]
|
||||||
fn event_property_is_applies() {
|
fn event_property_is_applies() {
|
||||||
use crate::push::condition::ScalarJsonValue;
|
use crate::push::condition::ScalarJsonValue;
|
||||||
|
@ -5,9 +5,7 @@ use crate::serde::from_raw_json_value;
|
|||||||
|
|
||||||
#[cfg(feature = "unstable-msc3931")]
|
#[cfg(feature = "unstable-msc3931")]
|
||||||
use super::RoomVersionFeature;
|
use super::RoomVersionFeature;
|
||||||
#[cfg(any(feature = "unstable-msc3758", feature = "unstable-msc3966"))]
|
use super::{PushCondition, RoomMemberCountIs, ScalarJsonValue};
|
||||||
use super::ScalarJsonValue;
|
|
||||||
use super::{PushCondition, RoomMemberCountIs};
|
|
||||||
|
|
||||||
impl Serialize for PushCondition {
|
impl Serialize for PushCondition {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
@ -33,7 +31,8 @@ impl<'de> Deserialize<'de> for PushCondition {
|
|||||||
"event_match"
|
"event_match"
|
||||||
| "contains_display_name"
|
| "contains_display_name"
|
||||||
| "room_member_count"
|
| "room_member_count"
|
||||||
| "sender_notification_permission" => {
|
| "sender_notification_permission"
|
||||||
|
| "event_property_is" => {
|
||||||
let helper: PushConditionSerDeHelper = from_raw_json_value(&json)?;
|
let helper: PushConditionSerDeHelper = from_raw_json_value(&json)?;
|
||||||
Ok(helper.into())
|
Ok(helper.into())
|
||||||
}
|
}
|
||||||
@ -42,11 +41,6 @@ impl<'de> Deserialize<'de> for PushCondition {
|
|||||||
let helper: PushConditionSerDeHelper = from_raw_json_value(&json)?;
|
let helper: PushConditionSerDeHelper = from_raw_json_value(&json)?;
|
||||||
Ok(helper.into())
|
Ok(helper.into())
|
||||||
}
|
}
|
||||||
#[cfg(feature = "unstable-msc3758")]
|
|
||||||
"com.beeper.msc3758.exact_event_match" => {
|
|
||||||
let helper: PushConditionSerDeHelper = from_raw_json_value(&json)?;
|
|
||||||
Ok(helper.into())
|
|
||||||
}
|
|
||||||
#[cfg(feature = "unstable-msc3966")]
|
#[cfg(feature = "unstable-msc3966")]
|
||||||
"org.matrix.msc3966.exact_event_property_contains" => {
|
"org.matrix.msc3966.exact_event_property_contains" => {
|
||||||
let helper: PushConditionSerDeHelper = from_raw_json_value(&json)?;
|
let helper: PushConditionSerDeHelper = from_raw_json_value(&json)?;
|
||||||
@ -106,13 +100,17 @@ enum PushConditionSerDeHelper {
|
|||||||
feature: RoomVersionFeature,
|
feature: RoomVersionFeature,
|
||||||
},
|
},
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc3758")]
|
EventPropertyIs {
|
||||||
#[serde(rename = "com.beeper.msc3758.exact_event_match")]
|
key: String,
|
||||||
EventPropertyIs { key: String, value: ScalarJsonValue },
|
value: ScalarJsonValue,
|
||||||
|
},
|
||||||
|
|
||||||
#[cfg(feature = "unstable-msc3966")]
|
#[cfg(feature = "unstable-msc3966")]
|
||||||
#[serde(rename = "org.matrix.msc3966.exact_event_property_contains")]
|
#[serde(rename = "org.matrix.msc3966.exact_event_property_contains")]
|
||||||
EventPropertyContains { key: String, value: ScalarJsonValue },
|
EventPropertyContains {
|
||||||
|
key: String,
|
||||||
|
value: ScalarJsonValue,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<PushConditionSerDeHelper> for PushCondition {
|
impl From<PushConditionSerDeHelper> for PushCondition {
|
||||||
@ -130,7 +128,6 @@ impl From<PushConditionSerDeHelper> for PushCondition {
|
|||||||
PushConditionSerDeHelper::RoomVersionSupports { feature } => {
|
PushConditionSerDeHelper::RoomVersionSupports { feature } => {
|
||||||
Self::RoomVersionSupports { feature }
|
Self::RoomVersionSupports { feature }
|
||||||
}
|
}
|
||||||
#[cfg(feature = "unstable-msc3758")]
|
|
||||||
PushConditionSerDeHelper::EventPropertyIs { key, value } => {
|
PushConditionSerDeHelper::EventPropertyIs { key, value } => {
|
||||||
Self::EventPropertyIs { key, value }
|
Self::EventPropertyIs { key, value }
|
||||||
}
|
}
|
||||||
@ -153,7 +150,6 @@ impl From<PushCondition> for PushConditionSerDeHelper {
|
|||||||
}
|
}
|
||||||
#[cfg(feature = "unstable-msc3931")]
|
#[cfg(feature = "unstable-msc3931")]
|
||||||
PushCondition::RoomVersionSupports { feature } => Self::RoomVersionSupports { feature },
|
PushCondition::RoomVersionSupports { feature } => Self::RoomVersionSupports { feature },
|
||||||
#[cfg(feature = "unstable-msc3758")]
|
|
||||||
PushCondition::EventPropertyIs { key, value } => Self::EventPropertyIs { key, value },
|
PushCondition::EventPropertyIs { key, value } => Self::EventPropertyIs { key, value },
|
||||||
#[cfg(feature = "unstable-msc3966")]
|
#[cfg(feature = "unstable-msc3966")]
|
||||||
PushCondition::EventPropertyContains { key, value } => {
|
PushCondition::EventPropertyContains { key, value } => {
|
||||||
|
@ -181,7 +181,6 @@ unstable-msc3554 = ["ruma-common/unstable-msc3554"]
|
|||||||
unstable-msc3575 = ["ruma-client-api?/unstable-msc3575"]
|
unstable-msc3575 = ["ruma-client-api?/unstable-msc3575"]
|
||||||
unstable-msc3618 = ["ruma-federation-api?/unstable-msc3618"]
|
unstable-msc3618 = ["ruma-federation-api?/unstable-msc3618"]
|
||||||
unstable-msc3723 = ["ruma-federation-api?/unstable-msc3723"]
|
unstable-msc3723 = ["ruma-federation-api?/unstable-msc3723"]
|
||||||
unstable-msc3758 = ["ruma-common/unstable-msc3758"]
|
|
||||||
unstable-msc3927 = ["ruma-common/unstable-msc3927"]
|
unstable-msc3927 = ["ruma-common/unstable-msc3927"]
|
||||||
unstable-msc3931 = ["ruma-common/unstable-msc3931"]
|
unstable-msc3931 = ["ruma-common/unstable-msc3931"]
|
||||||
unstable-msc3932 = ["ruma-common/unstable-msc3932"]
|
unstable-msc3932 = ["ruma-common/unstable-msc3932"]
|
||||||
@ -226,7 +225,6 @@ __ci = [
|
|||||||
"unstable-msc3575",
|
"unstable-msc3575",
|
||||||
"unstable-msc3618",
|
"unstable-msc3618",
|
||||||
"unstable-msc3723",
|
"unstable-msc3723",
|
||||||
"unstable-msc3758",
|
|
||||||
"unstable-msc3927",
|
"unstable-msc3927",
|
||||||
"unstable-msc3932",
|
"unstable-msc3932",
|
||||||
"unstable-msc3954",
|
"unstable-msc3954",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user