Do not ellipsize non-standard footers in chat messages

This commit is contained in:
Hocuri
2020-04-19 13:15:38 +02:00
committed by Alexander Krotov
parent 511727fdfa
commit 6e2f4d85a3

View File

@@ -44,7 +44,11 @@ pub fn simplify(mut input: String, is_chat_message: bool) -> (String, bool) {
let original_lines = &lines;
let lines = remove_message_footer(lines);
let (lines, mut has_nonstandard_footer) = remove_nonstandard_footer(lines);
let (lines, mut has_nonstandard_footer) = if !is_chat_message {
remove_nonstandard_footer(lines)
} else {
(lines, false)
};
let (lines, mut has_bottom_quote) = if !is_chat_message {
remove_bottom_quote(lines)
} else {
@@ -223,6 +227,14 @@ mod tests {
assert!(!is_forwarded);
}
#[test]
fn test_chat_message() {
let input = "Hi! How are you?\n\n---\n\nI am good.\n-- \nSent with my Delta Chat Messenger: https://delta.chat".to_string();
let (plain, is_forwarded) = simplify(input, true);
assert_eq!(plain, "Hi! How are you?\n\n---\n\nI am good.");
assert!(!is_forwarded);
}
#[test]
fn test_simplify_trim() {
let input = "line1\n\r\r\rline2".to_string();