adminroom: add server_in_room state cache accessor
Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
d2063013b4
commit
016270b33b
2 changed files with 21 additions and 0 deletions
|
@ -136,6 +136,11 @@ pub(crate) enum RoomAlias {
|
||||||
#[cfg_attr(test, derive(Debug))]
|
#[cfg_attr(test, derive(Debug))]
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
pub(crate) enum RoomStateCache {
|
pub(crate) enum RoomStateCache {
|
||||||
|
ServerInRoom {
|
||||||
|
server: Box<ServerName>,
|
||||||
|
room_id: Box<RoomId>,
|
||||||
|
},
|
||||||
|
|
||||||
RoomServers {
|
RoomServers {
|
||||||
room_id: Box<RoomId>,
|
room_id: Box<RoomId>,
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,6 +5,22 @@ use crate::{services, Result};
|
||||||
|
|
||||||
pub(crate) async fn room_state_cache(subcommand: RoomStateCache) -> Result<RoomMessageEventContent> {
|
pub(crate) async fn room_state_cache(subcommand: RoomStateCache) -> Result<RoomMessageEventContent> {
|
||||||
match subcommand {
|
match subcommand {
|
||||||
|
RoomStateCache::ServerInRoom {
|
||||||
|
server,
|
||||||
|
room_id,
|
||||||
|
} => {
|
||||||
|
let timer = tokio::time::Instant::now();
|
||||||
|
let result = services()
|
||||||
|
.rooms
|
||||||
|
.state_cache
|
||||||
|
.server_in_room(&server, &room_id);
|
||||||
|
let query_time = timer.elapsed();
|
||||||
|
|
||||||
|
Ok(RoomMessageEventContent::text_html(
|
||||||
|
format!("Query completed in {query_time:?}:\n\n```\n{result:?}```"),
|
||||||
|
format!("<p>Query completed in {query_time:?}:</p>\n<pre><code>{result:?}\n</code></pre>"),
|
||||||
|
))
|
||||||
|
},
|
||||||
RoomStateCache::RoomServers {
|
RoomStateCache::RoomServers {
|
||||||
room_id,
|
room_id,
|
||||||
} => {
|
} => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue