feat: Add command to enumerate extremities

This commit is contained in:
timedout committed 2026-10-30 00:51:51 +00:00
1 parent 14f5f62182
commit c6832372c2
2 files changed
+45 -1

No files matched your search

+41 -1
View File
@@ -14,7 +14,7 @@ use conduwuit::{
state_res::EventTypeExt,
trace, utils,
utils::{
stream::{IterStream, ReadyExt},
stream::{BroadbandExt, IterStream, ReadyExt},
string::EMPTY,
to_canonical_object,
},
@@ -1207,6 +1207,46 @@ impl crate::Context<'_> {
.await
}
pub(super) async fn room_extremities(&self, room_id: OwnedRoomId) -> Result {
let mut extremities = self
.services
.rooms
.state
.get_forward_extremities(&room_id)
.broad_filter_map(|event_id| async move {
self.services.rooms.timeline.get_pdu(&event_id).await.ok()
})
.collect::<Vec<_>>()
.await;
extremities.sort_by_key(|pdu| (pdu.depth, pdu.origin_server_ts));
if extremities.is_empty() {
return Err!("No room extremities.");
}
self.write_str("| Event ID | Kind | Sender | Timestamp | Depth |\n")
.await?;
self.write_str("| -------- | ---- | ------ | --------- | ----- |\n")
.await?;
for pdu in extremities {
let url = format!(
"https://matrix.to/#/{}/{}?via={}",
room_id,
pdu.event_id(),
self.services.server.name
);
self.write_str(&format!(
"| [`{}`]({url}) | `{}` | `{}` | `{}` | `{}` |\n",
pdu.event_id(),
pdu.kind(),
pdu.sender(),
pdu.origin_server_ts,
pdu.depth
))
.await?;
}
Ok(())
}
pub(super) async fn servers_in_backoff(
&self,
room_id: Option<OwnedRoomId>,
+4
View File
@@ -234,6 +234,10 @@ pub enum DebugCommand {
page: Option<usize>,
},
RoomExtremities {
room_id: OwnedRoomId,
},
/// Lists remote servers that are currently in a "backoff" state.
///
/// Servers in this list will not be contacted until the retry time elapses,