Skip to main content

tuwunel_admin/debug/
get_pdu.rs

1use ruma::OwnedEventId;
2use tuwunel_core::{Result, err};
3
4use crate::admin_command;
5
6#[admin_command]
7pub(super) async fn get_pdu(&self, event_id: OwnedEventId) -> Result {
8	let mut outlier = false;
9	let mut pdu_json = self
10		.services
11		.timeline
12		.get_non_outlier_pdu_json(&event_id)
13		.await;
14
15	if pdu_json.is_err() {
16		outlier = true;
17		pdu_json = self
18			.services
19			.timeline
20			.get_pdu_json(&event_id)
21			.await;
22	}
23
24	let json = pdu_json.map_err(|_| err!("PDU not found locally."))?;
25
26	let text = serde_json::to_string_pretty(&json)?;
27	let msg = if outlier {
28		"Outlier (Rejected / Soft Failed) PDU found in our database"
29	} else {
30		"PDU found in our database"
31	};
32
33	write!(self, "{msg}\n```json\n{text}\n```").await
34}