events: Don't send pretty-printed HTML fallback in replies
This commit is contained in:
parent
3c507afc90
commit
806d389e13
@ -23,7 +23,7 @@ server = []
|
|||||||
|
|
||||||
api = ["http", "thiserror"]
|
api = ["http", "thiserror"]
|
||||||
compat = ["ruma-macros/compat", "ruma-identifiers-validation/compat"]
|
compat = ["ruma-macros/compat", "ruma-identifiers-validation/compat"]
|
||||||
events = ["indoc", "thiserror"]
|
events = ["thiserror"]
|
||||||
# TODO: Use weak dependency features once MSRV >= 1.60
|
# TODO: Use weak dependency features once MSRV >= 1.60
|
||||||
js = ["js-sys", "getrandom/js", "uuid/js"]
|
js = ["js-sys", "getrandom/js", "uuid/js"]
|
||||||
markdown = ["pulldown-cmark"]
|
markdown = ["pulldown-cmark"]
|
||||||
@ -56,7 +56,6 @@ form_urlencoded = "1.0.0"
|
|||||||
getrandom = { version = "0.2.6", optional = true }
|
getrandom = { version = "0.2.6", optional = true }
|
||||||
http = { version = "0.2.2", optional = true }
|
http = { version = "0.2.2", optional = true }
|
||||||
indexmap = { version = "1.6.2", features = ["serde-1"] }
|
indexmap = { version = "1.6.2", features = ["serde-1"] }
|
||||||
indoc = { version = "1.0", optional = true }
|
|
||||||
itoa = "1.0.1"
|
itoa = "1.0.1"
|
||||||
js_int = { version = "0.2.0", features = ["serde"] }
|
js_int = { version = "0.2.0", features = ["serde"] }
|
||||||
js_option = "0.1.0"
|
js_option = "0.1.0"
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
use indoc::formatdoc;
|
|
||||||
|
|
||||||
use super::{FormattedBody, MessageType, OriginalRoomMessageEvent};
|
use super::{FormattedBody, MessageType, OriginalRoomMessageEvent};
|
||||||
|
|
||||||
pub fn get_message_quote_fallbacks(
|
pub fn get_message_quote_fallbacks(
|
||||||
@ -44,17 +42,15 @@ fn get_quotes(
|
|||||||
|
|
||||||
(
|
(
|
||||||
format!("> {emote_sign}<{sender}> {body}").replace('\n', "\n> "),
|
format!("> {emote_sign}<{sender}> {body}").replace('\n', "\n> "),
|
||||||
formatdoc!(
|
format!(
|
||||||
"
|
"<mx-reply>\
|
||||||
<mx-reply>
|
<blockquote>\
|
||||||
<blockquote>
|
<a href=\"https://matrix.to/#/{room_id}/{event_id}\">In reply to</a> \
|
||||||
<a href=\"https://matrix.to/#/{room_id}/{event_id}\">In reply to</a>
|
{emote_sign}<a href=\"https://matrix.to/#/{sender}\">{sender}</a>\
|
||||||
{emote_sign}<a href=\"https://matrix.to/#/{sender}\">{sender}</a>
|
<br>\
|
||||||
<br>
|
{html_body}\
|
||||||
{html_body}
|
</blockquote>\
|
||||||
</blockquote>
|
</mx-reply>"
|
||||||
</mx-reply>
|
|
||||||
"
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -98,8 +94,8 @@ mod tests {
|
|||||||
use super::OriginalRoomMessageEvent;
|
use super::OriginalRoomMessageEvent;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn plain_quote_fallback_multiline() {
|
fn fallback_multiline() {
|
||||||
let (plain_quote, _html_quote) =
|
let (plain_quote, html_quote) =
|
||||||
super::get_message_quote_fallbacks(&OriginalRoomMessageEvent {
|
super::get_message_quote_fallbacks(&OriginalRoomMessageEvent {
|
||||||
content: RoomMessageEventContent::text_plain("multi\nline"),
|
content: RoomMessageEventContent::text_plain("multi\nline"),
|
||||||
event_id: event_id!("$1598361704261elfgc:localhost").to_owned(),
|
event_id: event_id!("$1598361704261elfgc:localhost").to_owned(),
|
||||||
@ -110,5 +106,16 @@ mod tests {
|
|||||||
});
|
});
|
||||||
|
|
||||||
assert_eq!(plain_quote, "> <@alice:example.com> multi\n> line");
|
assert_eq!(plain_quote, "> <@alice:example.com> multi\n> line");
|
||||||
|
assert_eq!(
|
||||||
|
html_quote,
|
||||||
|
"<mx-reply>\
|
||||||
|
<blockquote>\
|
||||||
|
<a href=\"https://matrix.to/#/!n8f893n9:example.com/$1598361704261elfgc:localhost\">In reply to</a> \
|
||||||
|
<a href=\"https://matrix.to/#/@alice:example.com\">@alice:example.com</a>\
|
||||||
|
<br>\
|
||||||
|
multi\nline\
|
||||||
|
</blockquote>\
|
||||||
|
</mx-reply>"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user