From df54e6555a2689666e2a54a1842011c8fe4a9ef8 Mon Sep 17 00:00:00 2001 From: projectmoon Date: Sun, 31 Jan 2021 14:46:38 +0000 Subject: [PATCH] Use 'username bubbles' in responses instead of straight user ID. --- src/commands.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/commands.rs b/src/commands.rs index c2aa26a..71a275f 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -76,6 +76,11 @@ pub trait ResponseExtractor { impl ResponseExtractor for CommandResult { /// Error message in bolded HTML. fn message_html(&self, username: &str) -> String { + //TODO use user display name too + let username = format!( + "{}", + username, username + ); match self { Ok(resp) => format!("

{}

{}

", username, resp.html).replace("\n", "
"), Err(e) => format!("

{}

{}

", username, e.html()).replace("\n", "
"), @@ -112,6 +117,15 @@ mod tests { }; } + #[test] + fn command_result_extractor_creates_bubble() { + let result = Execution::new("test".to_string()); + let message = result.message_html("@myuser:example.com"); + assert!(message.contains( + "@myuser:example.com" + )); + } + #[tokio::test] async fn unrecognized_command() { let db = crate::db::Database::new_temp().unwrap();