aboutsummaryrefslogtreecommitdiff
path: root/lib/room.cpp
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-12-08 23:07:14 +0100
committerTobias Fella <fella@posteo.de>2021-12-08 23:07:14 +0100
commita0ce17dfe793c924205b449c026f2f776b032ff3 (patch)
tree99f5b7e45777a240e5fc87f5349cd0edd5371c91 /lib/room.cpp
parent9fb07da8451f024085061e2985e9be384e7beb5c (diff)
downloadlibquotient-a0ce17dfe793c924205b449c026f2f776b032ff3.tar.gz
libquotient-a0ce17dfe793c924205b449c026f2f776b032ff3.zip
Store encryptedevent in decrypted roomevents
Diffstat (limited to 'lib/room.cpp')
-rw-r--r--lib/room.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/room.cpp b/lib/room.cpp
index 8e348089..b3a092f3 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -1517,6 +1517,7 @@ void Room::handleRoomKeyEvent(const RoomKeyEvent& roomKeyEvent,
auto decrypted = decryptMessage(*encryptedEvent);
if(decrypted) {
auto oldEvent = event->replaceEvent(std::move(decrypted));
+ decrypted->setOriginalEvent(std::move(oldEvent));
emit replacedEvent(event->event(), rawPtr(oldEvent));
d->undecryptedEvents[roomKeyEvent.sessionId()] -= eventId;
}
@@ -2596,7 +2597,8 @@ Room::Changes Room::Private::addNewMessageEvents(RoomEvents&& events)
if(auto* encrypted = eventCast<EncryptedEvent>(events[i])) {
auto decrypted = q->decryptMessage(*encrypted);
if(decrypted) {
- events[i] = std::move(decrypted);
+ auto oldEvent = std::exchange(events[i], std::move(decrypted));
+ events[i]->setOriginalEvent(std::move(oldEvent));
} else {
undecryptedEvents[encrypted->sessionId()] += encrypted->id();
}
@@ -2760,7 +2762,8 @@ void Room::Private::addHistoricalMessageEvents(RoomEvents&& events)
if(auto* encrypted = eventCast<EncryptedEvent>(events[i])) {
auto decrypted = q->decryptMessage(*encrypted);
if(decrypted) {
- events[i] = std::move(decrypted);
+ auto oldEvent = std::exchange(events[i], std::move(decrypted));
+ events[i]->setOriginalEvent(std::move(oldEvent));
} else {
undecryptedEvents[encrypted->sessionId()] += encrypted->id();
}