remove unnecessary tracing of pdu conversions
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
b7a41f283f
commit
da984d49cf
3 changed files with 15 additions and 16 deletions
|
@ -11,7 +11,7 @@ use serde_json::{
|
||||||
value::{to_raw_value, RawValue as RawJsonValue},
|
value::{to_raw_value, RawValue as RawJsonValue},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{implement, warn, Error, Result};
|
use crate::{implement, Error, Result};
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
struct ExtractRedactedBecause {
|
struct ExtractRedactedBecause {
|
||||||
|
@ -19,14 +19,13 @@ struct ExtractRedactedBecause {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
pub fn redact(&mut self, room_version_id: &RoomVersionId, reason: &Self) -> Result {
|
||||||
pub fn redact(&mut self, room_version_id: RoomVersionId, reason: &Self) -> Result {
|
|
||||||
self.unsigned = None;
|
self.unsigned = None;
|
||||||
|
|
||||||
let mut content =
|
let mut content =
|
||||||
serde_json::from_str(self.content.get()).map_err(|_| Error::bad_database("PDU in db has invalid content."))?;
|
serde_json::from_str(self.content.get()).map_err(|_| Error::bad_database("PDU in db has invalid content."))?;
|
||||||
|
|
||||||
redact_content_in_place(&mut content, &room_version_id, self.kind.to_string())
|
redact_content_in_place(&mut content, room_version_id, self.kind.to_string())
|
||||||
.map_err(|e| Error::Redaction(self.sender.server_name().to_owned(), e))?;
|
.map_err(|e| Error::Redaction(self.sender.server_name().to_owned(), e))?;
|
||||||
|
|
||||||
self.unsigned = Some(
|
self.unsigned = Some(
|
||||||
|
|
|
@ -8,10 +8,10 @@ use ruma::{
|
||||||
};
|
};
|
||||||
use serde_json::{json, value::Value as JsonValue};
|
use serde_json::{json, value::Value as JsonValue};
|
||||||
|
|
||||||
use crate::{implement, warn};
|
use crate::implement;
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_sync_room_event(&self) -> Raw<AnySyncTimelineEvent> {
|
pub fn to_sync_room_event(&self) -> Raw<AnySyncTimelineEvent> {
|
||||||
let (redacts, content) = self.copy_redacts();
|
let (redacts, content) = self.copy_redacts();
|
||||||
let mut json = json!({
|
let mut json = json!({
|
||||||
|
@ -36,8 +36,8 @@ pub fn to_sync_room_event(&self) -> Raw<AnySyncTimelineEvent> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This only works for events that are also AnyRoomEvents.
|
/// This only works for events that are also AnyRoomEvents.
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_any_event(&self) -> Raw<AnyEphemeralRoomEvent> {
|
pub fn to_any_event(&self) -> Raw<AnyEphemeralRoomEvent> {
|
||||||
let (redacts, content) = self.copy_redacts();
|
let (redacts, content) = self.copy_redacts();
|
||||||
let mut json = json!({
|
let mut json = json!({
|
||||||
|
@ -62,8 +62,8 @@ pub fn to_any_event(&self) -> Raw<AnyEphemeralRoomEvent> {
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_room_event(&self) -> Raw<AnyTimelineEvent> {
|
pub fn to_room_event(&self) -> Raw<AnyTimelineEvent> {
|
||||||
let (redacts, content) = self.copy_redacts();
|
let (redacts, content) = self.copy_redacts();
|
||||||
let mut json = json!({
|
let mut json = json!({
|
||||||
|
@ -88,8 +88,8 @@ pub fn to_room_event(&self) -> Raw<AnyTimelineEvent> {
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_message_like_event(&self) -> Raw<AnyMessageLikeEvent> {
|
pub fn to_message_like_event(&self) -> Raw<AnyMessageLikeEvent> {
|
||||||
let (redacts, content) = self.copy_redacts();
|
let (redacts, content) = self.copy_redacts();
|
||||||
let mut json = json!({
|
let mut json = json!({
|
||||||
|
@ -114,8 +114,8 @@ pub fn to_message_like_event(&self) -> Raw<AnyMessageLikeEvent> {
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[implement(super::Pdu)]
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
|
#[implement(super::Pdu)]
|
||||||
pub fn to_state_event_value(&self) -> JsonValue {
|
pub fn to_state_event_value(&self) -> JsonValue {
|
||||||
let mut json = json!({
|
let mut json = json!({
|
||||||
"content": self.content,
|
"content": self.content,
|
||||||
|
@ -134,14 +134,14 @@ pub fn to_state_event_value(&self) -> JsonValue {
|
||||||
json
|
json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_state_event(&self) -> Raw<AnyStateEvent> {
|
pub fn to_state_event(&self) -> Raw<AnyStateEvent> {
|
||||||
serde_json::from_value(self.to_state_event_value()).expect("Raw::from_value always works")
|
serde_json::from_value(self.to_state_event_value()).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_sync_state_event(&self) -> Raw<AnySyncStateEvent> {
|
pub fn to_sync_state_event(&self) -> Raw<AnySyncStateEvent> {
|
||||||
let mut json = json!({
|
let mut json = json!({
|
||||||
"content": self.content,
|
"content": self.content,
|
||||||
|
@ -159,8 +159,8 @@ pub fn to_sync_state_event(&self) -> Raw<AnySyncStateEvent> {
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_stripped_state_event(&self) -> Raw<AnyStrippedStateEvent> {
|
pub fn to_stripped_state_event(&self) -> Raw<AnyStrippedStateEvent> {
|
||||||
let json = json!({
|
let json = json!({
|
||||||
"content": self.content,
|
"content": self.content,
|
||||||
|
@ -172,8 +172,8 @@ pub fn to_stripped_state_event(&self) -> Raw<AnyStrippedStateEvent> {
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_stripped_spacechild_state_event(&self) -> Raw<HierarchySpaceChildEvent> {
|
pub fn to_stripped_spacechild_state_event(&self) -> Raw<HierarchySpaceChildEvent> {
|
||||||
let json = json!({
|
let json = json!({
|
||||||
"content": self.content,
|
"content": self.content,
|
||||||
|
@ -186,8 +186,8 @@ pub fn to_stripped_spacechild_state_event(&self) -> Raw<HierarchySpaceChildEvent
|
||||||
serde_json::from_value(json).expect("Raw::from_value always works")
|
serde_json::from_value(json).expect("Raw::from_value always works")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
#[implement(super::Pdu)]
|
#[implement(super::Pdu)]
|
||||||
#[tracing::instrument(skip(self), level = "debug")]
|
|
||||||
pub fn to_member_event(&self) -> Raw<StateEvent<RoomMemberEventContent>> {
|
pub fn to_member_event(&self) -> Raw<StateEvent<RoomMemberEventContent>> {
|
||||||
let mut json = json!({
|
let mut json = json!({
|
||||||
"content": self.content,
|
"content": self.content,
|
||||||
|
|
|
@ -1024,7 +1024,7 @@ impl Service {
|
||||||
|
|
||||||
let room_version_id = self.services.state.get_room_version(&pdu.room_id).await?;
|
let room_version_id = self.services.state.get_room_version(&pdu.room_id).await?;
|
||||||
|
|
||||||
pdu.redact(room_version_id, reason)?;
|
pdu.redact(&room_version_id, reason)?;
|
||||||
|
|
||||||
let obj = utils::to_canonical_object(&pdu)
|
let obj = utils::to_canonical_object(&pdu)
|
||||||
.map_err(|e| err!(Database(error!(?event_id, ?e, "Failed to convert PDU to canonical JSON"))))?;
|
.map_err(|e| err!(Database(error!(?event_id, ?e, "Failed to convert PDU to canonical JSON"))))?;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue