From 2d4772337df47794fb0b1734bda209177a989515 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 2 Oct 2020 18:33:41 +0200 Subject: Matrix: show m.emote, m.notice and m.location --- src/plugins/Matrix.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'src') 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(); + 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()) -- cgit v1.2.3