mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 12:16:54 +00:00
fix: Properly move /send redaction fields
This commit is contained in:
1 parent
20fe43d200
commit
63578eba8c
1 file changed
+20
-1
+20
-1
@@ -6,7 +6,10 @@ use conduwuit::{
|
||||
matrix::pdu::{PartialPdu, sticky},
|
||||
utils,
|
||||
};
|
||||
use ruma::{api::client::message::send_message_event, events::MessageLikeEventType};
|
||||
use ruma::{
|
||||
OwnedEventId, api::client::message::send_message_event, events::MessageLikeEventType,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use serde_json::from_str;
|
||||
|
||||
use crate::{Ruma, client_ip::ClientIp};
|
||||
@@ -77,6 +80,13 @@ pub(crate) async fn send_message_event_route(
|
||||
|
||||
let content = from_str(body.body.body.json().get())
|
||||
.map_err(|e| err!(Request(BadJson("Invalid JSON body: {e}"))))?;
|
||||
let redacts = if body.body.event_type == MessageLikeEventType::RoomRedaction {
|
||||
from_str::<MaybeRedaction>(body.body.body.json().get())
|
||||
.ok()
|
||||
.and_then(|r| r.redacts)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let event_id = services
|
||||
.rooms
|
||||
@@ -97,6 +107,7 @@ pub(crate) async fn send_message_event_route(
|
||||
} else {
|
||||
None
|
||||
},
|
||||
redacts,
|
||||
..Default::default()
|
||||
},
|
||||
sender_user,
|
||||
@@ -116,3 +127,11 @@ pub(crate) async fn send_message_event_route(
|
||||
|
||||
Ok(send_message_event::v3::Response::new(event_id))
|
||||
}
|
||||
|
||||
/// Struct containing exclusively the `redacts` field for MSC4169 compatible
|
||||
/// redaction moving.
|
||||
#[derive(Deserialize)]
|
||||
struct MaybeRedaction {
|
||||
#[serde(default)]
|
||||
redacts: Option<OwnedEventId>,
|
||||
}
|
||||
Reference in new issue
Block a user