diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-10-19 23:33:23 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-10-20 02:06:49 +0200 |
commit | 6a2b5008be8104680826fe40fa8e674e9357c044 (patch) | |
tree | c7d88abee4e71ebbba68384c1686829656933b1c /src/plugins | |
parent | 41fe990530c546b4cac7e000b40481f87fb33305 (diff) |
Add thumbnail loading animation
Use correct ref in matrix replies,
make text that contains our user id also count as a mention.
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/Matrix.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp index 35f5302..ff0d498 100644 --- a/src/plugins/Matrix.cpp +++ b/src/plugins/Matrix.cpp @@ -462,7 +462,7 @@ namespace QuickMedia { // 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 && me) - new_message->mentions_me = message_contains_user_mention(new_message->body, me->display_name) || message_contains_user_mention(new_message->body, "@room"); + new_message->mentions_me = message_contains_user_mention(new_message->body, me->display_name) || message_contains_user_mention(new_message->body, me->user_id) || message_contains_user_mention(new_message->body, "@room"); new_messages.push_back(std::move(new_message)); } @@ -978,17 +978,23 @@ namespace QuickMedia { static std::string create_body_for_message_reply(const Message *message, const std::string &body) { return "> <" + message->user->user_id + "> " + block_quote(get_reply_message(message)) + "\n\n" + body; } + + static std::string extract_homeserver_from_room_id(const std::string &room_id) { + size_t sep_index = room_id.find(':'); + if(sep_index != std::string::npos) + return room_id.substr(sep_index + 1); + return ""; + } - static std::string create_formatted_body_for_message_reply(const Message *message, const std::string &body) { + static std::string create_formatted_body_for_message_reply(RoomData *room, const Message *message, const std::string &body) { std::string formatted_body = body; std::string related_to_body = get_reply_message(message); html_escape_sequences(formatted_body); html_escape_sequences(related_to_body); - // TODO: Fix invalid.url, etc to use same as element. This is required to navigate to reply message in element mobile. // TODO: Add keybind to navigate to the reply message, which would also depend on this formatting. return "<mx-reply>" "<blockquote>" - "<a href=\"https://invalid.url\">In reply to</a>" + "<a href=\"https://matrix.to/#/" + room->id + "/" + message->event_id + "?via=" + extract_homeserver_from_room_id(room->id) + "\">In reply to</a>" "<a href=\"https://matrix.to/#/" + message->user->user_id + "\">" + message->user->user_id + "</a><br>" + std::move(related_to_body) + "</blockquote>" "</mx-reply>" + std::move(formatted_body); @@ -1018,7 +1024,7 @@ namespace QuickMedia { relates_to_json.AddMember("m.in_reply_to", std::move(in_reply_to_json), relates_to_json.GetAllocator()); std::string message_reply_body = create_body_for_message_reply(relates_to_message_raw, body); // Yes, the reply is to the edited message but the event_id reference is to the original message... - std::string formatted_message_reply_body = create_formatted_body_for_message_reply(relates_to_message_raw, body); + std::string formatted_message_reply_body = create_formatted_body_for_message_reply(room, relates_to_message_raw, body); rapidjson::Document request_data(rapidjson::kObjectType); request_data.AddMember("msgtype", "m.text", request_data.GetAllocator()); // TODO: Allow image reply? element doesn't do that but we could! |