aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-10-10 00:07:44 +0200
committerTobias Fella <fella@posteo.de>2021-10-10 00:07:44 +0200
commitfe77279cf0f7de006db40a828cc2fb7261e8e0bd (patch)
tree66bee117f8a3d97b59020a9df1b57ac4eb417d21
parent7b516cdf0b987e542b1e4cd4556ecb2bfbde3ff9 (diff)
downloadlibquotient-fe77279cf0f7de006db40a828cc2fb7261e8e0bd.tar.gz
libquotient-fe77279cf0f7de006db40a828cc2fb7261e8e0bd.zip
Keep the reply when replacing an event
-rw-r--r--lib/room.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index a923bf9a..e1d41fc3 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -2251,8 +2251,13 @@ bool Room::Private::processRedaction(const RedactionEvent& redaction)
RoomEventPtr makeReplaced(const RoomEvent& target,
const RoomMessageEvent& replacement)
{
+ const auto &targetReply = target.contentJson()["m.relates_to"].toObject();
+ auto newContent = replacement.contentJson().value("m.new_content"_ls).toObject();
+ if (!targetReply.empty()) {
+ newContent["m.relates_to"] = targetReply;
+ }
auto originalJson = target.originalJsonObject();
- originalJson[ContentKeyL] = replacement.contentJson().value("m.new_content"_ls);
+ originalJson[ContentKeyL] = newContent;
auto unsignedData = originalJson.take(UnsignedKeyL).toObject();
auto relations = unsignedData.take("m.relations"_ls).toObject();