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