From 9bf163d51a252fb5a611e88c2e0b4123a98169e1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 17 Oct 2020 09:40:10 +0200 Subject: Matrix: show reply messages embedded in messages that reply to them, like element does --- plugins/Matrix.hpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'plugins/Matrix.hpp') diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 8d078a0..9f58b24 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include namespace QuickMedia { // Dummy, only play one video. TODO: Play all videos in room, as related videos? @@ -91,6 +91,11 @@ namespace QuickMedia { std::string avatar_url; std::string prev_batch; bool initial_fetch_finished = false; + + // These are messages fetched with |Matrix::get_message_by_id|. Needed to show replies, when replying to old message not part of /sync. + // The value is nullptr if the message is fetched and cached but the event if referenced an invalid message. + // TODO: Verify if replied to messages are also part of /sync; then this is not needed. + std::unordered_map> fetched_messages_by_event_id; private: std::mutex user_mutex; std::mutex room_mutex; @@ -157,6 +162,9 @@ namespace QuickMedia { std::shared_ptr get_me(std::shared_ptr room); + // Returns nullptr if message cant be found. Note: cached + std::shared_ptr get_message_by_id(RoomData *room, const std::string &event_id); + bool use_tor = false; private: PluginResult sync_response_to_body_items(const rapidjson::Document &root, RoomSyncMessages &room_messages); @@ -165,6 +173,7 @@ namespace QuickMedia { void events_add_user_read_markers(const rapidjson::Value &events_json, RoomData *room_data); void events_add_messages(const rapidjson::Value &events_json, std::shared_ptr &room_data, MessageDirection message_dir, RoomSyncMessages *room_messages, bool has_unread_notifications); void events_set_room_name(const rapidjson::Value &events_json, RoomData *room_data); + std::shared_ptr parse_message_event(const rapidjson::Value &event_item_json, RoomData *room_data); PluginResult upload_file(std::shared_ptr room, const std::string &filepath, UploadInfo &file_info, UploadInfo &thumbnail_info, std::string &err_msg); std::shared_ptr get_edited_message_original_message(RoomData *room_data, std::shared_ptr message); -- cgit v1.2.3