aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-09-30 22:05:41 +0200
committerdec05eba <dec05eba@protonmail.com>2020-09-30 22:05:41 +0200
commit9602603135f456d906192112288dcd84429c8fee (patch)
tree6a6dafff82f3e38b8e18b74f474ef61965917339 /plugins
parente1a8d10b61c5f8ca092ba3aa458b661da29ba447 (diff)
Matrix: implement message editing
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 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<Message> get_edited_message_original_message(RoomData *room_data, std::shared_ptr<Message> message);
private:
std::unordered_map<std::string, std::unique_ptr<RoomData>> room_data_by_id;
std::string user_id;