diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-02 18:33:41 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-02 18:33:41 +0200 |
commit | 2d4772337df47794fb0b1734bda209177a989515 (patch) | |
tree | 90898435bccf5fb6062014b40a94774b75eb8cf1 /src/plugins | |
parent | 87c7a3c659735dbe4bda63712372e3dbdf807c3b (diff) |
Matrix: show m.emote, m.notice and m.location
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 32cabe1..585664a 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -523,6 +523,9 @@ namespace QuickMedia { } auto message = std::make_shared<Message>(); + std::string prefix; + + // TODO: Also show joins, leave, invites, bans, kicks, mutes, etc if(strcmp(content_type.asCString(), "m.text") == 0) { message->type = MessageType::TEXT; @@ -556,13 +559,26 @@ namespace QuickMedia { message->url = homeserver + "/_matrix/media/r0/download/" + url_json.asString().substr(6); message->type = MessageType::FILE; + } else if(strcmp(content_type.asCString(), "m.emote") == 0) { // this is a /me message, TODO: show /me messages differently + message->type = MessageType::TEXT; + prefix = "*" + room_data->user_info[user_it->second].display_name + "* "; + } else if(strcmp(content_type.asCString(), "m.notice") == 0) { // TODO: show notices differently + message->type = MessageType::TEXT; + prefix = "* NOTICE * "; + } else if(strcmp(content_type.asCString(), "m.location") == 0) { // TODO: show locations differently + const Json::Value &geo_uri_json = content_json["geo_uri"]; + if(geo_uri_json.isString()) + prefix = geo_uri_json.asString() + " | "; + + message->type = MessageType::TEXT; + message->thumbnail_url = message_content_extract_thumbnail_url(content_json, homeserver); } else { continue; } message->user_id = user_it->second; message->event_id = event_id_str; - message->body = body_json.asString(); + message->body = prefix + body_json.asString(); message->replaces_event_id = std::move(replaces_event_id); // TODO: Is @room ok? shouldn't we also check if the user has permission to do @room? (only when notifications are limited to @mentions) if(has_unread_notifications && !username.empty()) |