aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-05 09:12:41 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-05 09:15:34 +0200
commit27d5c7dcc37b0064801741a7c1e5500160c4c2d7 (patch)
tree62db36d36d462e7757585eb77467a9d3c0c1e8a7 /src
parentcfef90021917df0052bb49e9e35298260e7ca38c (diff)
Commit before redesign of code
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Matrix.cpp33
1 files changed, 8 insertions, 25 deletions
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 "<mx-reply>"
@@ -1093,7 +1076,7 @@ namespace QuickMedia {
"</mx-reply>" + std::move(formatted_body);
}
- // TODO: Add formatted_body just like element does with <mx-reply><blockquote... and also support greentext with that
+ // TODO: Support greentext
PluginResult Matrix::post_reply(const std::string &room_id, const std::string &body, void *relates_to) {
auto room = get_room_by_id(room_id);
if(!room) {