Use 'username bubbles' in responses instead of straight user ID.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b3c4d8a38c
commit
df54e6555a
|
@ -76,6 +76,11 @@ pub trait ResponseExtractor {
|
||||||
impl ResponseExtractor for CommandResult {
|
impl ResponseExtractor for CommandResult {
|
||||||
/// Error message in bolded HTML.
|
/// Error message in bolded HTML.
|
||||||
fn message_html(&self, username: &str) -> String {
|
fn message_html(&self, username: &str) -> String {
|
||||||
|
//TODO use user display name too
|
||||||
|
let username = format!(
|
||||||
|
"<a href=\"https://matrix.to/#/{}\">{}</a>",
|
||||||
|
username, username
|
||||||
|
);
|
||||||
match self {
|
match self {
|
||||||
Ok(resp) => format!("<p>{}</p><p>{}</p>", username, resp.html).replace("\n", "<br/>"),
|
Ok(resp) => format!("<p>{}</p><p>{}</p>", username, resp.html).replace("\n", "<br/>"),
|
||||||
Err(e) => format!("<p>{}</p><p>{}</p>", username, e.html()).replace("\n", "<br/>"),
|
Err(e) => format!("<p>{}</p><p>{}</p>", username, e.html()).replace("\n", "<br/>"),
|
||||||
|
@ -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(
|
||||||
|
"<a href=\"https://matrix.to/#/@myuser:example.com\">@myuser:example.com</a>"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn unrecognized_command() {
|
async fn unrecognized_command() {
|
||||||
let db = crate::db::Database::new_temp().unwrap();
|
let db = crate::db::Database::new_temp().unwrap();
|
||||||
|
|
Loading…
Reference in New Issue