feat: Move list-extremities to graph room subcommand

This commit is contained in:
timedout committed 2026-10-31 22:30:23 +00:00
1 parent 4f128af921
commit 5de3d74436
4 files changed
+69 -51

No files matched your search

+1 -41
View File
@@ -13,7 +13,7 @@ use conduwuit::{
},
trace, utils,
utils::{
stream::{BroadbandExt, IterStream, ReadyExt},
stream::{IterStream, ReadyExt},
string::EMPTY,
},
warn,
@@ -1084,44 +1084,4 @@ 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(())
}
}