aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-10-02 16:50:19 +0200
committerdec05eba <dec05eba@protonmail.com>2020-10-02 16:50:19 +0200
commita6a309c0c9828d62e81632a863108d6b5233d1ba (patch)
treed8d6bda0c01cc7679af9b6eb02b1fe8bc4e39ab1
parente9627c23c07d9060f2a6bdccfcd81a0e28adfe9f (diff)
Matrix: show audio and files in body
-rw-r--r--plugins/Matrix.hpp4
-rw-r--r--src/plugins/Matrix.cpp24
2 files changed, 27 insertions, 1 deletions
diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp
index bbf35db..a4f0cf4 100644
--- a/plugins/Matrix.hpp
+++ b/plugins/Matrix.hpp
@@ -16,7 +16,9 @@ namespace QuickMedia {
enum class MessageType {
TEXT,
IMAGE,
- VIDEO
+ VIDEO,
+ AUDIO,
+ FILE
};
struct Message {
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index 60fc8a9..32cabe1 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -542,6 +542,20 @@ namespace QuickMedia {
message->url = homeserver + "/_matrix/media/r0/download/" + url_json.asString().substr(6);
message->thumbnail_url = message_content_extract_thumbnail_url(content_json, homeserver);
message->type = MessageType::VIDEO;
+ } else if(strcmp(content_type.asCString(), "m.audio") == 0) {
+ const Json::Value &url_json = content_json["url"];
+ if(!url_json.isString() || strncmp(url_json.asCString(), "mxc://", 6) != 0)
+ continue;
+
+ message->url = homeserver + "/_matrix/media/r0/download/" + url_json.asString().substr(6);
+ message->type = MessageType::AUDIO;
+ } else if(strcmp(content_type.asCString(), "m.file") == 0) {
+ const Json::Value &url_json = content_json["url"];
+ if(!url_json.isString() || strncmp(url_json.asCString(), "mxc://", 6) != 0)
+ continue;
+
+ message->url = homeserver + "/_matrix/media/r0/download/" + url_json.asString().substr(6);
+ message->type = MessageType::FILE;
} else {
continue;
}
@@ -890,6 +904,12 @@ namespace QuickMedia {
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;
}
return "> <" + room_data->user_info[message->user_id].user_id + "> " + std::move(related_to_body) + "\n\n" + body;
}
@@ -1157,6 +1177,10 @@ namespace QuickMedia {
new_message->type = MessageType::IMAGE;
} else if(strcmp(content_type.asCString(), "m.video") == 0) {
new_message->type = MessageType::VIDEO;
+ } else if(strcmp(content_type.asCString(), "m.audio") == 0) {
+ new_message->type = MessageType::AUDIO;
+ } else if(strcmp(content_type.asCString(), "m.file") == 0) {
+ new_message->type = MessageType::FILE;
} else {
return nullptr;
}