From fe77279cf0f7de006db40a828cc2fb7261e8e0bd Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sun, 10 Oct 2021 00:07:44 +0200 Subject: Keep the reply when replacing an event --- lib/room.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/room.cpp') 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(); -- cgit v1.2.3