Skip to main content

tuwunel_admin/debug/
get_short_pdu.rs

1use tuwunel_core::{Result, err};
2use tuwunel_matrix::pdu::{PduId, RawPduId};
3use tuwunel_service::rooms::short::ShortRoomId;
4
5use crate::admin_command;
6
7#[admin_command]
8pub(super) async fn get_short_pdu(&self, shortroomid: ShortRoomId, count: i64) -> Result {
9	let pdu_id: RawPduId = PduId { shortroomid, count: count.into() }.into();
10
11	let pdu_json = self
12		.services
13		.timeline
14		.get_pdu_json_from_id(&pdu_id)
15		.await;
16
17	let json = pdu_json.map_err(|_| err!("PDU not found locally."))?;
18
19	let json_text = serde_json::to_string_pretty(&json)?;
20
21	write!(self, "```json\n{json_text}\n```").await
22}