diff --git a/rust/src/push/evaluator.rs b/rust/src/push/evaluator.rs
index 59c53b1776..48e670478b 100644
--- a/rust/src/push/evaluator.rs
+++ b/rust/src/push/evaluator.rs
@@ -117,7 +117,7 @@ impl PushRuleEvaluator {
msc3931_enabled: bool,
) -> Result<Self, Error> {
let body = match flattened_keys.get("content.body") {
- Some(JsonValue::Value(SimpleJsonValue::Str(s))) => s.clone(),
+ Some(JsonValue::Value(SimpleJsonValue::Str(s))) => s.clone().into_owned(),
_ => String::new(),
};
@@ -313,13 +313,15 @@ impl PushRuleEvaluator {
};
let pattern = match &*exact_event_match.value_type {
- EventMatchPatternType::UserId => user_id,
- EventMatchPatternType::UserLocalpart => get_localpart_from_id(user_id)?,
+ EventMatchPatternType::UserId => user_id.to_owned(),
+ EventMatchPatternType::UserLocalpart => {
+ get_localpart_from_id(user_id)?.to_owned()
+ }
};
self.match_event_property_contains(
exact_event_match.key.clone(),
- Cow::Borrowed(&SimpleJsonValue::Str(pattern.to_string())),
+ Cow::Borrowed(&SimpleJsonValue::Str(Cow::Owned(pattern))),
)?
}
KnownCondition::ContainsDisplayName => {
@@ -494,7 +496,7 @@ fn push_rule_evaluator() {
let mut flattened_keys = BTreeMap::new();
flattened_keys.insert(
"content.body".to_string(),
- JsonValue::Value(SimpleJsonValue::Str("foo bar bob hello".to_string())),
+ JsonValue::Value(SimpleJsonValue::Str(Cow::Borrowed("foo bar bob hello"))),
);
let evaluator = PushRuleEvaluator::py_new(
flattened_keys,
@@ -522,7 +524,7 @@ fn test_requires_room_version_supports_condition() {
let mut flattened_keys = BTreeMap::new();
flattened_keys.insert(
"content.body".to_string(),
- JsonValue::Value(SimpleJsonValue::Str("foo bar bob hello".to_string())),
+ JsonValue::Value(SimpleJsonValue::Str(Cow::Borrowed("foo bar bob hello"))),
);
let flags = vec![RoomVersionFeatures::ExtensibleEvents.as_str().to_string()];
let evaluator = PushRuleEvaluator::py_new(
|