From 27d5c7dcc37b0064801741a7c1e5500160c4c2d7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 5 Oct 2020 09:12:41 +0200 Subject: Commit before redesign of code --- src/plugins/Matrix.cpp | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'src/plugins/Matrix.cpp') diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index ca3fc28..fb7c00d 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -1033,7 +1033,7 @@ namespace QuickMedia { return result; } - static std::string create_body_for_message_reply(const Message *message, const std::string &body) { + static std::string get_reply_message(const Message *message) { std::string related_to_body; switch(message->type) { case MessageType::TEXT: { @@ -1056,33 +1056,16 @@ namespace QuickMedia { related_to_body = "sent a file"; break; } - return "> <" + message->user->user_id + "> " + block_quote(std::move(related_to_body)) + "\n\n" + body; + return related_to_body; + } + + static std::string create_body_for_message_reply(const Message *message, const std::string &body) { + return "> <" + message->user->user_id + "> " + block_quote(get_reply_message(message)) + "\n\n" + body; } static std::string create_formatted_body_for_message_reply(const Message *message, const std::string &body) { - std::string related_to_body; - switch(message->type) { - case MessageType::TEXT: { - if(!message->replaces_event_id.empty() && strncmp(message->body.c_str(), " * ", 3) == 0) - related_to_body = remove_reply_formatting(message->body.substr(3)); - else - related_to_body = remove_reply_formatting(message->body); - break; - } - case MessageType::IMAGE: - related_to_body = "sent an image"; - break; - case MessageType::VIDEO: - related_to_body = "sent a video"; - break; - case MessageType::AUDIO: - related_to_body = "sent an audio file"; - break; - case MessageType::FILE: - related_to_body = "sent a file"; - break; - } std::string formatted_body = body; + std::string related_to_body = get_reply_message(message); html_escape_sequences(formatted_body); html_escape_sequences(related_to_body); return "" @@ -1093,7 +1076,7 @@ namespace QuickMedia { "" + std::move(formatted_body); } - // TODO: Add formatted_body just like element does with