From 6a2b5008be8104680826fe40fa8e674e9357c044 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 19 Oct 2020 23:33:23 +0200 Subject: Add thumbnail loading animation Use correct ref in matrix replies, make text that contains our user id also count as a mention. --- src/plugins/Matrix.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/plugins') 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 "" "
" - "In reply to" + "id + "/" + message->event_id + "?via=" + extract_homeserver_from_room_id(room->id) + "\">In reply to" "user->user_id + "\">" + message->user->user_id + "
" + std::move(related_to_body) + "
" "
" + 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! -- cgit v1.2.3