From e1a8d10b61c5f8ca092ba3aa458b661da29ba447 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 30 Sep 2020 19:07:05 +0200 Subject: Matrix: add message replying with ctrl+r, also use shared_ptr for BodyItem --- 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 97ba3cc..07c6f61 100644 --- a/plugins/Matrix.hpp +++ b/plugins/Matrix.hpp @@ -6,6 +6,7 @@ namespace QuickMedia { struct UserInfo { + std::string user_id; std::string display_name; std::string avatar_url; sf::Color display_name_color; @@ -20,10 +21,12 @@ namespace QuickMedia { struct Message { // Index into |RoomData.user_info| size_t user_id; + std::string event_id; std::string body; std::string url; std::string thumbnail_url; MessageType type; + bool is_reply; }; struct MessageInfo { @@ -39,7 +42,8 @@ namespace QuickMedia { // The value is an index to |user_info|. std::unordered_map user_info_by_user_id; std::vector user_info; - std::vector messages; + std::vector> messages; + std::unordered_map> message_by_event_id; std::string name; std::string avatar_url; std::string prev_batch; @@ -73,6 +77,10 @@ namespace QuickMedia { // |url| should only be set when uploading media. // TODO: Make api better. 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); + + // 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); PluginResult login(const std::string &username, const std::string &password, const std::string &homeserver, std::string &err_msg); PluginResult logout(); -- cgit v1.2.3