mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-15 15:28:50 -05:00
Implement MSC3966: Add a push rule condition to search for a value in an array. (#15045)
The `exact_event_property_contains` condition can be used to search for a value inside of an array.
This commit is contained in:
parent
157c571f3e
commit
119e0795a5
9 changed files with 176 additions and 42 deletions
|
|
@ -15,8 +15,8 @@
|
|||
#![feature(test)]
|
||||
use std::collections::BTreeSet;
|
||||
use synapse::push::{
|
||||
evaluator::PushRuleEvaluator, Condition, EventMatchCondition, FilteredPushRules, PushRules,
|
||||
SimpleJsonValue,
|
||||
evaluator::PushRuleEvaluator, Condition, EventMatchCondition, FilteredPushRules, JsonValue,
|
||||
PushRules, SimpleJsonValue,
|
||||
};
|
||||
use test::Bencher;
|
||||
|
||||
|
|
@ -27,15 +27,15 @@ fn bench_match_exact(b: &mut Bencher) {
|
|||
let flattened_keys = [
|
||||
(
|
||||
"type".to_string(),
|
||||
SimpleJsonValue::Str("m.text".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("m.text".to_string())),
|
||||
),
|
||||
(
|
||||
"room_id".to_string(),
|
||||
SimpleJsonValue::Str("!room:server".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("!room:server".to_string())),
|
||||
),
|
||||
(
|
||||
"content.body".to_string(),
|
||||
SimpleJsonValue::Str("test message".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("test message".to_string())),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
|
|
@ -54,6 +54,7 @@ fn bench_match_exact(b: &mut Bencher) {
|
|||
vec![],
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
@ -76,15 +77,15 @@ fn bench_match_word(b: &mut Bencher) {
|
|||
let flattened_keys = [
|
||||
(
|
||||
"type".to_string(),
|
||||
SimpleJsonValue::Str("m.text".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("m.text".to_string())),
|
||||
),
|
||||
(
|
||||
"room_id".to_string(),
|
||||
SimpleJsonValue::Str("!room:server".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("!room:server".to_string())),
|
||||
),
|
||||
(
|
||||
"content.body".to_string(),
|
||||
SimpleJsonValue::Str("test message".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("test message".to_string())),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
|
|
@ -103,6 +104,7 @@ fn bench_match_word(b: &mut Bencher) {
|
|||
vec![],
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
@ -125,15 +127,15 @@ fn bench_match_word_miss(b: &mut Bencher) {
|
|||
let flattened_keys = [
|
||||
(
|
||||
"type".to_string(),
|
||||
SimpleJsonValue::Str("m.text".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("m.text".to_string())),
|
||||
),
|
||||
(
|
||||
"room_id".to_string(),
|
||||
SimpleJsonValue::Str("!room:server".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("!room:server".to_string())),
|
||||
),
|
||||
(
|
||||
"content.body".to_string(),
|
||||
SimpleJsonValue::Str("test message".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("test message".to_string())),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
|
|
@ -152,6 +154,7 @@ fn bench_match_word_miss(b: &mut Bencher) {
|
|||
vec![],
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
@ -174,15 +177,15 @@ fn bench_eval_message(b: &mut Bencher) {
|
|||
let flattened_keys = [
|
||||
(
|
||||
"type".to_string(),
|
||||
SimpleJsonValue::Str("m.text".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("m.text".to_string())),
|
||||
),
|
||||
(
|
||||
"room_id".to_string(),
|
||||
SimpleJsonValue::Str("!room:server".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("!room:server".to_string())),
|
||||
),
|
||||
(
|
||||
"content.body".to_string(),
|
||||
SimpleJsonValue::Str("test message".to_string()),
|
||||
JsonValue::Value(SimpleJsonValue::Str("test message".to_string())),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
|
|
@ -201,6 +204,7 @@ fn bench_eval_message(b: &mut Bencher) {
|
|||
vec![],
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue