aboutsummaryrefslogtreecommitdiff
path: root/lib/events/encryptedevent.cpp
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-11-27 01:34:44 +0100
committerTobias Fella <fella@posteo.de>2021-12-01 21:56:59 +0100
commit3128df9daa196b2cf3cdb8e029e22d79c397ff66 (patch)
tree458d6ca810022ec6250e3e7621e1732982c9c030 /lib/events/encryptedevent.cpp
parent8020505eb582479cf62d0157fe866f63a888f1a9 (diff)
downloadlibquotient-3128df9daa196b2cf3cdb8e029e22d79c397ff66.tar.gz
libquotient-3128df9daa196b2cf3cdb8e029e22d79c397ff66.zip
Apply even more suggestions
Diffstat (limited to 'lib/events/encryptedevent.cpp')
-rw-r--r--lib/events/encryptedevent.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/events/encryptedevent.cpp b/lib/events/encryptedevent.cpp
index 0290f973..c9257584 100644
--- a/lib/events/encryptedevent.cpp
+++ b/lib/events/encryptedevent.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include "encryptedevent.h"
+#include "roommessageevent.h"
using namespace Quotient;
@@ -30,3 +31,24 @@ EncryptedEvent::EncryptedEvent(const QJsonObject& obj)
{
qCDebug(E2EE) << "Encrypted event from" << senderId();
}
+
+RoomEventPtr EncryptedEvent::createDecrypted(const QString &decrypted) const
+{
+ auto eventObject = QJsonDocument::fromJson(decrypted.toUtf8()).object();
+ eventObject["event_id"] = id();
+ eventObject["sender"] = senderId();
+ eventObject["origin_server_ts"] = originTimestamp().toMSecsSinceEpoch();
+ if(contentJson().contains("m.relates_to")) {
+ auto relates = contentJson()["m.relates_to"].toObject();
+ auto content = eventObject["content"].toObject();
+ content["m.relates_to"] = relates;
+ eventObject["content"] = content;
+ }
+ if(unsignedJson().contains("redacts")) {
+ auto redacts = unsignedJson()["redacts"].toString();
+ auto unsign = eventObject["unsigned"].toObject();
+ unsign["redacts"] = redacts;
+ eventObject["unsigned"] = unsign;
+ }
+ return makeEvent<RoomMessageEvent>(eventObject);
+}