From 9602603135f456d906192112288dcd84429c8fee Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 30 Sep 2020 22:05:41 +0200 Subject: Matrix: implement message editing --- plugins/Matrix.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'plugins/Matrix.hpp') diff --git a/plugins/Matrix.hpp b/plugins/Matrix.hpp index 07c6f61..7a588e8 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -25,8 +25,8 @@ namespace QuickMedia { std::string body; std::string url; std::string thumbnail_url; + std::string replaces_event_id; MessageType type; - bool is_reply; }; struct MessageInfo { @@ -37,6 +37,7 @@ namespace QuickMedia { }; struct RoomData { + std::string id; // Each room has its own list of user data, even if multiple rooms has the same user // because users can have different display names and avatars in different rooms. // The value is an index to |user_info|. @@ -79,6 +80,8 @@ namespace QuickMedia { PluginResult post_message(const std::string &room_id, const std::string &body, const std::string &url = "", MessageType msgtype = MessageType::TEXT, MessageInfo *info = nullptr); // |relates_to| is from |BodyItem.userdata| and is of type |Message*| PluginResult post_reply(const std::string &room_id, const std::string &body, void *relates_to); + // |relates_to| is from |BodyItem.userdata| and is of type |Message*| + PluginResult post_edit(const std::string &room_id, const std::string &body, void *relates_to); // TODO: Make this work for all image types and videos and regular files PluginResult post_file(const std::string &room_id, const std::string &filepath); @@ -89,12 +92,17 @@ namespace QuickMedia { PluginResult on_start_typing(const std::string &room_id); PluginResult on_stop_typing(const std::string &room_id); + + // |message| is from |BodyItem.userdata| and is of type |Message*| + bool was_message_posted_by_me(const std::string &room_id, void *message) const; private: PluginResult sync_response_to_body_items(const Json::Value &root); PluginResult get_previous_room_messages(const std::string &room_id, RoomData *room_data); void events_add_user_info(const Json::Value &events_json, RoomData *room_data); void events_add_messages(const Json::Value &events_json, RoomData *room_data, MessageDirection message_dir); void events_set_room_name(const Json::Value &events_json, RoomData *room_data); + + std::shared_ptr get_edited_message_original_message(RoomData *room_data, std::shared_ptr message); private: std::unordered_map> room_data_by_id; std::string user_id; -- cgit v1.2.3