diff --git a/src/admin/debug/commands.rs b/src/admin/debug/commands.rs index 0fd3c91b..2aa6078f 100644 --- a/src/admin/debug/commands.rs +++ b/src/admin/debug/commands.rs @@ -106,7 +106,7 @@ pub(super) async fn get_pdu(&self, event_id: Box) -> Result) -> Result { @@ -108,33 +108,15 @@ pub(super) async fn remote_user_in_rooms(&self, user_id: Box) -> Result< rooms.sort_by_key(|r| r.1); rooms.reverse(); - let output_plain = format!( - "Rooms {user_id} shares with us ({}):\n{}", + let output = format!( + "Rooms {user_id} shares with us ({}):\n```\n{}\n```", rooms.len(), rooms .iter() - .map(|(id, members, name)| format!("{id}\tMembers: {members}\tName: {name}")) + .map(|(id, members, name)| format!("{id} | Members: {members} | Name: {name}")) .collect::>() .join("\n") ); - let output_html = format!( - "\n\t\t\n{}
Rooms {user_id} shares with us \ - ({})
idmembersname
", - rooms.len(), - rooms - .iter() - .fold(String::new(), |mut output, (id, members, name)| { - writeln!( - output, - "{}\t{}\t{}", - id, - members, - escape_html(name) - ) - .expect("should be able to write to string buffer"); - output - }) - ); - Ok(RoomMessageEventContent::text_html(output_plain, output_html)) + Ok(RoomMessageEventContent::text_markdown(output)) } diff --git a/src/admin/room/directory.rs b/src/admin/room/directory.rs index 1080356a..0bdaf56d 100644 --- a/src/admin/room/directory.rs +++ b/src/admin/room/directory.rs @@ -1,11 +1,9 @@ -use std::fmt::Write; - use clap::Subcommand; use conduit::Result; use futures::StreamExt; use ruma::{events::room::message::RoomMessageEventContent, RoomId}; -use crate::{escape_html, get_room_info, Command, PAGE_SIZE}; +use crate::{get_room_info, Command, PAGE_SIZE}; #[derive(Debug, Subcommand)] pub(crate) enum RoomDirectoryCommand { @@ -68,32 +66,15 @@ pub(super) async fn process(command: RoomDirectoryCommand, context: &Command<'_> return Ok(RoomMessageEventContent::text_plain("No more rooms.")); }; - let output_plain = format!( - "Rooms:\n{}", + let output = format!( + "Rooms (page {page}):\n```\n{}\n```", rooms .iter() - .map(|(id, members, name)| format!("{id}\tMembers: {members}\tName: {name}")) + .map(|(id, members, name)| format!("{id} | Members: {members} | Name: {name}")) .collect::>() .join("\n") ); - let output_html = format!( - "\n\t\t\n{}
Room directory - page \ - {page}
idmembersname
", - rooms - .iter() - .fold(String::new(), |mut output, (id, members, name)| { - writeln!( - output, - "{}\t{}\t{}", - escape_html(id.as_ref()), - members, - escape_html(name.as_ref()) - ) - .expect("should be able to write to string buffer"); - output - }) - ); - Ok(RoomMessageEventContent::text_html(output_plain, output_html)) + Ok(RoomMessageEventContent::text_markdown(output)) }, } } diff --git a/src/admin/server/commands.rs b/src/admin/server/commands.rs index de6ad98a..f5879b03 100644 --- a/src/admin/server/commands.rs +++ b/src/admin/server/commands.rs @@ -21,7 +21,10 @@ pub(super) async fn uptime(&self) -> Result { #[admin_command] pub(super) async fn show_config(&self) -> Result { // Construct and send the response - Ok(RoomMessageEventContent::text_plain(format!("{}", self.services.globals.config))) + Ok(RoomMessageEventContent::text_markdown(format!( + "```\n{}\n```", + self.services.globals.config + ))) } #[admin_command] diff --git a/src/core/config/mod.rs b/src/core/config/mod.rs index 7a5c6d08..512cb48b 100644 --- a/src/core/config/mod.rs +++ b/src/core/config/mod.rs @@ -1441,7 +1441,7 @@ impl Config { impl fmt::Display for Config { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - writeln!(f, "Active config values:\n\n").expect("wrote line to formatter stream"); + writeln!(f, "Active config values:\n").expect("wrote line to formatter stream"); let mut line = |key: &str, val: &str| { writeln!(f, "{key}: {val}").expect("wrote line to formatter stream"); };