diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-01 12:16:14 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-01 12:16:14 +0200 |
commit | 925139ea3ba6634a267586db0e60af1ea60cdc6f (patch) | |
tree | 50e1c0dd5061642f3a7ce3ebece524eb24666c3f /src/plugins | |
parent | a1ff5cb86eaa32e6e4ee194e87d8036c74be8dc9 (diff) |
Matrix: fix replying broken formatting, including reply message in body
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index ed3b0af..257feb4 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -771,14 +771,26 @@ namespace QuickMedia { return PluginResult::OK; } + static std::string remove_reply_formatting(const std::string &str) { + if(strncmp(str.c_str(), "> <@", 4) == 0) { + size_t index = str.find("> ", 4); + if(index != std::string::npos) { + size_t msg_begin = str.find("\n\n", index + 2); + if(msg_begin != std::string::npos) + return str.substr(msg_begin + 2); + } + } + return str; + } + static std::string create_body_for_message_reply(const RoomData *room_data, 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 = message->body.substr(3); + related_to_body = remove_reply_formatting(message->body.substr(3)); else - related_to_body = message->body; + related_to_body = remove_reply_formatting(message->body); break; } case MessageType::IMAGE: |