diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-02 16:50:19 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-02 16:50:19 +0200 |
commit | a6a309c0c9828d62e81632a863108d6b5233d1ba (patch) | |
tree | d8d6bda0c01cc7679af9b6eb02b1fe8bc4e39ab1 /src/plugins | |
parent | e9627c23c07d9060f2a6bdccfcd81a0e28adfe9f (diff) |
Matrix: show audio and files in body
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
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; } |