Commit e519b13d authored by Christopher Davis's avatar Christopher Davis Committed by Daniel Garcia Moreno

Resolving @altiera's discussions

parent 1ec4e0a7
......@@ -740,9 +740,8 @@ pub fn parse_room_message(baseu: &Url, roomid: String, msg: &JsonValue) -> Messa
let c = &msg["content"];
let mtype = c["msgtype"].as_str().unwrap_or("");
let body = c["body"].as_str().unwrap_or("");
let formatted_body = c["formatted_body"].as_str().unwrap_or("");
let format = c["format"].as_str().unwrap_or("");
let formatted_body = c["formatted_body"].as_str().map(|s| String::from(s));
let format = c["format"].as_str().map(|s| String::from(s));
let mut url = String::new();
let mut thumb = String::new();
......@@ -767,8 +766,8 @@ pub fn parse_room_message(baseu: &Url, roomid: String, msg: &JsonValue) -> Messa
url: Some(url),
thumb: Some(thumb),
id: Some(String::from(id)),
formatted_body: Some(String::from(formatted_body)),
format: Some(String::from(format)),
formatted_body: formatted_body,
format: format,
}
}
......
......@@ -1342,7 +1342,7 @@ impl AppOp {
}
}
pub fn send_message(&mut self, mut msg: String) {
pub fn send_message(&mut self, msg: String) {
if msg.is_empty() {
// Not sending empty messages
return;
......@@ -1367,19 +1367,19 @@ impl AppOp {
};
if msg.starts_with("/me ") {
msg = msg.trim_left_matches("/me ").to_owned();
m.body = msg.to_string();
m.body = msg.trim_left_matches("/me").to_owned();
m.mtype = strn!("m.emote");
}
/* reenable autoscroll to jump to new message in history */
self.autoscroll = true;
let md_parsed_msg = markdown_to_html(&msg, &ComrakOptions::default());
if md_parsed_msg.replace("<p>","").replace("</p>","") != msg.clone() + "\n" {
// Riot does not properly show emotes with Markdown;
// Emotes with markdown have a newline after the username
if m.mtype != "m.emote" {
// Riot does not properly show emotes with Markdown;
// Emotes with markdown have a newline after the username
if m.mtype != "m.emote" {
let md_parsed_msg = markdown_to_html(&msg, &ComrakOptions::default());
if md_parsed_msg != String::from("<p>") + &msg + &String::from("</p>\n") {
m.formatted_body = Some(md_parsed_msg);
m.format = Some(String::from("org.matrix.custom.html"));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment