aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-11-06 13:11:30 +0100
committerdec05eba <dec05eba@protonmail.com>2022-11-06 13:11:36 +0100
commit0b4e30d37a34bde1e3b0416a563897fcb233b429 (patch)
treea3b9f745c6bca7c7b9bfee67d686bc94115e424d
parent5dc3fec277aa543b2cdb2305f56bc2ac15efa8e4 (diff)
Matrix: post reply should use the last edited message in the raw body
-rw-r--r--src/Text.cpp2
-rw-r--r--src/plugins/Matrix.cpp15
2 files changed, 14 insertions, 3 deletions
diff --git a/src/Text.cpp b/src/Text.cpp
index 26574bf..7692eef 100644
--- a/src/Text.cpp
+++ b/src/Text.cpp
@@ -1293,7 +1293,7 @@ namespace QuickMedia
// TODO: Dont do this here! it's slow, but it's needed to process the change before the next event
updateGeometry();
- if(editable && (dirtyCaret || caretMoveDirection != CaretMoveDirection::NONE)) {
+ if(dirtyCaret || caretMoveDirection != CaretMoveDirection::NONE) {
updateCaret();
dirtyCaret = false;
caretMoveDirection = CaretMoveDirection::NONE;
diff --git a/src/plugins/Matrix.cpp b/src/plugins/Matrix.cpp
index db37a97..0fcc1c3 100644
--- a/src/plugins/Matrix.cpp
+++ b/src/plugins/Matrix.cpp
@@ -3483,8 +3483,19 @@ namespace QuickMedia {
"</mx-reply>" + std::move(formatted_body);
}
+ static Message* get_latest_message_in_edit_chain(Message *message) {
+ while(message) {
+ Message *replaced_by = message->replaced_by.get();
+ if(!replaced_by)
+ break;
+ message = replaced_by;
+ }
+ return message;
+ }
+
PluginResult Matrix::post_reply(RoomData *room, const std::string &body, void *relates_to, std::string &event_id_response, const std::string &custom_transaction_id, const std::optional<UploadInfo> &file_info, const std::optional<UploadInfo> &thumbnail_info) {
Message *relates_to_message_raw = (Message*)relates_to;
+ Message *related_to_text_message = get_latest_message_in_edit_chain(relates_to_message_raw);
std::string transaction_id = custom_transaction_id;
if(transaction_id.empty())
@@ -3502,8 +3513,8 @@ namespace QuickMedia {
rapidjson::Document relates_to_json(rapidjson::kObjectType);
relates_to_json.AddMember("m.in_reply_to", std::move(in_reply_to_json), relates_to_json.GetAllocator());
- std::string message_reply_body = create_body_for_message_reply(relates_to_message_raw, body); // Yes, the reply is to the edited message but the event_id reference is to the original message...
- std::string formatted_message_reply_body = create_formatted_body_for_message_reply(room, relates_to_message_raw, body);
+ std::string message_reply_body = create_body_for_message_reply(related_to_text_message, body); // Yes, the reply is to the edited message but the event_id reference is to the original message...
+ std::string formatted_message_reply_body = create_formatted_body_for_message_reply(room, related_to_text_message, body);
rapidjson::Document request_data(rapidjson::kObjectType);
request_data.AddMember("msgtype", rapidjson::StringRef(file_info ? content_type_to_message_type(file_info->content_type) : "m.text"), request_data.GetAllocator());