common: Instrument push condition matching
This commit is contained in:
parent
088d1872b7
commit
1bce0f0c96
@ -21,6 +21,7 @@ use ruma_serde::{Raw, StringEnum};
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "unstable-pre-spec")]
|
||||
use serde_json::Value as JsonValue;
|
||||
use tracing::instrument;
|
||||
|
||||
use crate::PrivOwnedStr;
|
||||
|
||||
@ -99,6 +100,7 @@ impl Ruleset {
|
||||
///
|
||||
/// * `event` - The raw JSON of a room message event.
|
||||
/// * `context` - The context of the message and room at the time of the event.
|
||||
#[instrument(skip_all, fields(context.room_id = %context.room_id))]
|
||||
pub fn get_match<T>(
|
||||
&self,
|
||||
event: &Raw<T>,
|
||||
@ -116,6 +118,7 @@ impl Ruleset {
|
||||
///
|
||||
/// * `event` - The raw JSON of a room message event.
|
||||
/// * `context` - The context of the message and room at the time of the event.
|
||||
#[instrument(skip_all, fields(context.room_id = %context.room_id))]
|
||||
pub fn get_actions<T>(&self, event: &Raw<T>, context: &PushConditionRoomCtx) -> &[Action] {
|
||||
self.get_match(event, context).map(|rule| rule.actions()).unwrap_or(&[])
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ use js_int::{Int, UInt};
|
||||
use ruma_serde::Raw;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{to_value as to_json_value, value::Value as JsonValue};
|
||||
use tracing::warn;
|
||||
use tracing::{instrument, warn};
|
||||
use wildmatch::WildMatch;
|
||||
|
||||
use crate::{power_levels::NotificationPowerLevels, RoomId, UserId};
|
||||
@ -277,6 +277,7 @@ impl FlattenedJson {
|
||||
}
|
||||
|
||||
/// Flatten and insert the `value` at `path`.
|
||||
#[instrument(skip(self, value))]
|
||||
fn flatten_value(&mut self, value: JsonValue, path: String) {
|
||||
match value {
|
||||
JsonValue::Object(fields) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user