aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}