aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-30 19:07:05 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-30 19:08:05 +0200
commite1a8d10b61c5f8ca092ba3aa458b661da29ba447 (patch)
tree4de5ca75c3d19e4bd4c5c25a4362768b3e994326 /plugins
parent86d228bfc3e9c81c011c31bc81a908a21f975bfb (diff)
Matrix: add message replying with ctrl+r, also use shared_ptr for BodyItem
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Matrix.hpp10
1 files changed, 9 insertions, 1 deletions
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<std::string, size_t> user_info_by_user_id;
std::vector<UserInfo> user_info;
- std::vector<Message> messages;
+ std::vector<std::shared_ptr<Message>> messages;
+ std::unordered_map<std::string, std::shared_ptr<Message>> 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();