mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-06-26 16:26:37 +02:00
Also fixes: - Transaction IDs leaking in event route - Age not being set for event relations or threads - Both of the above for search results Notes down concern with relations table
61 lines
1.2 KiB
Rust
61 lines
1.2 KiB
Rust
use clap::Subcommand;
|
|
use conduwuit::{PduCount, Result, utils::stream::TryTools};
|
|
use futures::TryStreamExt;
|
|
use ruma::OwnedRoomOrAliasId;
|
|
|
|
use crate::{admin_command, admin_command_dispatch};
|
|
|
|
#[admin_command_dispatch]
|
|
#[derive(Debug, Subcommand)]
|
|
/// Query tables from database
|
|
pub(crate) enum RoomTimelineCommand {
|
|
Pdus {
|
|
room_id: OwnedRoomOrAliasId,
|
|
|
|
from: Option<String>,
|
|
|
|
#[arg(short, long)]
|
|
limit: Option<usize>,
|
|
},
|
|
|
|
Last {
|
|
room_id: OwnedRoomOrAliasId,
|
|
},
|
|
}
|
|
|
|
#[admin_command]
|
|
pub(super) async fn last(&self, room_id: OwnedRoomOrAliasId) -> Result {
|
|
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
|
|
|
let result = self
|
|
.services
|
|
.rooms
|
|
.timeline
|
|
.last_timeline_count(&room_id)
|
|
.await?;
|
|
|
|
self.write_str(&format!("{result:#?}")).await
|
|
}
|
|
|
|
#[admin_command]
|
|
pub(super) async fn pdus(
|
|
&self,
|
|
room_id: OwnedRoomOrAliasId,
|
|
from: Option<String>,
|
|
limit: Option<usize>,
|
|
) -> Result {
|
|
let room_id = self.services.rooms.alias.resolve(&room_id).await?;
|
|
|
|
let from: Option<PduCount> = from.as_deref().map(str::parse).transpose()?;
|
|
|
|
let result: Vec<_> = self
|
|
.services
|
|
.rooms
|
|
.timeline
|
|
.pdus_rev(&room_id, from)
|
|
.try_take(limit.unwrap_or(3))
|
|
.try_collect()
|
|
.await?;
|
|
|
|
self.write_str(&format!("{result:#?}")).await
|
|
}
|