mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-15 05:06:53 +00:00
fix: Record redacted_because_id instead of redacted_because
This commit is contained in:
3 files changed
+14
-12
No files matched your search
@@ -3,7 +3,7 @@ use std::collections::{HashSet, VecDeque};
|
||||
use axum::extract::State;
|
||||
use conduwuit::{Err, Event, Result, debug, info, trace, utils::to_canonical_object, warn};
|
||||
use ruma::{OwnedEventId, api::federation::event::get_missing_events};
|
||||
use serde_json::{json, value::RawValue};
|
||||
use serde_json::value::RawValue;
|
||||
use service::rooms::event_handler::GET_MISSING_EVENTS_MAX_BATCH_SIZE;
|
||||
|
||||
use super::AccessCheck;
|
||||
@@ -91,7 +91,7 @@ pub(crate) async fn get_missing_events_route(
|
||||
.await
|
||||
{
|
||||
debug!(%next_event_id, origin = %body.identity, "redacting event origin cannot see");
|
||||
pdu.redact(&room_version, json!({}))?;
|
||||
pdu.redact(&room_version, None)?;
|
||||
}
|
||||
|
||||
trace!(
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
use ruma::{RoomVersionId, canonical_json::redact_content_in_place};
|
||||
use serde_json::{Value as JsonValue, json, value::to_raw_value};
|
||||
use serde_json::{json, value::to_raw_value};
|
||||
|
||||
use crate::{Err, Result, err};
|
||||
|
||||
impl super::Pdu {
|
||||
pub fn redact(&mut self, room_version_id: &RoomVersionId, reason: JsonValue) -> Result {
|
||||
pub fn redact(
|
||||
&mut self,
|
||||
room_version_id: &RoomVersionId,
|
||||
redacted_because: Option<&ruma::EventId>,
|
||||
) -> Result {
|
||||
let Some(rules) = room_version_id.rules() else {
|
||||
return Err!("Cannot redact event for unknown room version {room_version_id}");
|
||||
};
|
||||
@@ -20,15 +24,13 @@ impl super::Pdu {
|
||||
|
||||
redact_content_in_place(&mut content, &rules.redaction, self.kind.to_string());
|
||||
|
||||
let reason = serde_json::to_value(reason).expect("Failed to preserialize reason");
|
||||
|
||||
let redacted_because = json!({
|
||||
"redacted_because": reason,
|
||||
});
|
||||
|
||||
self.unsigned = to_raw_value(&redacted_because)
|
||||
if let Some(event_id) = redacted_because {
|
||||
self.unsigned = to_raw_value(&json!({
|
||||
"redacted_because_id": event_id,
|
||||
}))
|
||||
.expect("Failed to serialize unsigned")
|
||||
.into();
|
||||
}
|
||||
|
||||
self.content = to_raw_value(&content).expect("Failed to serialize content");
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ impl super::Service {
|
||||
.get_room_version(&pdu.room_id_or_hash())
|
||||
.await?;
|
||||
|
||||
pdu.redact(&room_version_id, reason.to_value())?;
|
||||
pdu.redact(&room_version_id, Some(reason.event_id()))?;
|
||||
|
||||
let obj = utils::to_canonical_object(&pdu).map_err(|e| {
|
||||
err!(Database(error!(%event_id, ?e, "Failed to convert PDU to canonical JSON")))
|
||||
|
||||
Reference in new issue
Block a user