mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2025-08-03 20:44:11 -04:00
Support for MSC3758: exact_event_match push condition (#14964)
This specifies to search for an exact value match, instead of string globbing. It only works across non-compound JSON values (null, boolean, integer, and strings).
This commit is contained in:
parent
cf5233b783
commit
14be78d492
9 changed files with 356 additions and 41 deletions
|
@ -16,6 +16,7 @@
|
|||
use std::collections::BTreeSet;
|
||||
use synapse::push::{
|
||||
evaluator::PushRuleEvaluator, Condition, EventMatchCondition, FilteredPushRules, PushRules,
|
||||
SimpleJsonValue,
|
||||
};
|
||||
use test::Bencher;
|
||||
|
||||
|
@ -24,9 +25,18 @@ extern crate test;
|
|||
#[bench]
|
||||
fn bench_match_exact(b: &mut Bencher) {
|
||||
let flattened_keys = [
|
||||
("type".to_string(), "m.text".to_string()),
|
||||
("room_id".to_string(), "!room:server".to_string()),
|
||||
("content.body".to_string(), "test message".to_string()),
|
||||
(
|
||||
"type".to_string(),
|
||||
SimpleJsonValue::Str("m.text".to_string()),
|
||||
),
|
||||
(
|
||||
"room_id".to_string(),
|
||||
SimpleJsonValue::Str("!room:server".to_string()),
|
||||
),
|
||||
(
|
||||
"content.body".to_string(),
|
||||
SimpleJsonValue::Str("test message".to_string()),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
@ -43,6 +53,7 @@ fn bench_match_exact(b: &mut Bencher) {
|
|||
true,
|
||||
vec![],
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -63,9 +74,18 @@ fn bench_match_exact(b: &mut Bencher) {
|
|||
#[bench]
|
||||
fn bench_match_word(b: &mut Bencher) {
|
||||
let flattened_keys = [
|
||||
("type".to_string(), "m.text".to_string()),
|
||||
("room_id".to_string(), "!room:server".to_string()),
|
||||
("content.body".to_string(), "test message".to_string()),
|
||||
(
|
||||
"type".to_string(),
|
||||
SimpleJsonValue::Str("m.text".to_string()),
|
||||
),
|
||||
(
|
||||
"room_id".to_string(),
|
||||
SimpleJsonValue::Str("!room:server".to_string()),
|
||||
),
|
||||
(
|
||||
"content.body".to_string(),
|
||||
SimpleJsonValue::Str("test message".to_string()),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
@ -82,6 +102,7 @@ fn bench_match_word(b: &mut Bencher) {
|
|||
true,
|
||||
vec![],
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -102,9 +123,18 @@ fn bench_match_word(b: &mut Bencher) {
|
|||
#[bench]
|
||||
fn bench_match_word_miss(b: &mut Bencher) {
|
||||
let flattened_keys = [
|
||||
("type".to_string(), "m.text".to_string()),
|
||||
("room_id".to_string(), "!room:server".to_string()),
|
||||
("content.body".to_string(), "test message".to_string()),
|
||||
(
|
||||
"type".to_string(),
|
||||
SimpleJsonValue::Str("m.text".to_string()),
|
||||
),
|
||||
(
|
||||
"room_id".to_string(),
|
||||
SimpleJsonValue::Str("!room:server".to_string()),
|
||||
),
|
||||
(
|
||||
"content.body".to_string(),
|
||||
SimpleJsonValue::Str("test message".to_string()),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
@ -121,6 +151,7 @@ fn bench_match_word_miss(b: &mut Bencher) {
|
|||
true,
|
||||
vec![],
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
@ -141,9 +172,18 @@ fn bench_match_word_miss(b: &mut Bencher) {
|
|||
#[bench]
|
||||
fn bench_eval_message(b: &mut Bencher) {
|
||||
let flattened_keys = [
|
||||
("type".to_string(), "m.text".to_string()),
|
||||
("room_id".to_string(), "!room:server".to_string()),
|
||||
("content.body".to_string(), "test message".to_string()),
|
||||
(
|
||||
"type".to_string(),
|
||||
SimpleJsonValue::Str("m.text".to_string()),
|
||||
),
|
||||
(
|
||||
"room_id".to_string(),
|
||||
SimpleJsonValue::Str("!room:server".to_string()),
|
||||
),
|
||||
(
|
||||
"content.body".to_string(),
|
||||
SimpleJsonValue::Str("test message".to_string()),
|
||||
),
|
||||
]
|
||||
.into_iter()
|
||||
.collect();
|
||||
|
@ -160,6 +200,7 @@ fn bench_eval_message(b: &mut Bencher) {
|
|||
true,
|
||||
vec![],
|
||||
false,
|
||||
false,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue