diff options
author | Tobias Fella <9750016+TobiasFella@users.noreply.github.com> | 2021-11-28 20:58:38 +0100 |
---|---|---|
committer | Tobias Fella <fella@posteo.de> | 2021-12-01 21:56:59 +0100 |
commit | 9217026e46d7ac0d761cc5206d7ef00978558c47 (patch) | |
tree | e703d58f0fef4559e759511989349fb6051ea7f9 /lib | |
parent | dcc4556a761f96ae6c71115bf6297feca32581bf (diff) | |
download | libquotient-9217026e46d7ac0d761cc5206d7ef00978558c47.tar.gz libquotient-9217026e46d7ac0d761cc5206d7ef00978558c47.zip |
Apply suggestions from code review
Co-authored-by: Alexey Rusakov <Kitsune-Ral@users.sf.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/connection.cpp | 3 | ||||
-rw-r--r-- | lib/encryptionmanager.cpp | 2 | ||||
-rw-r--r-- | lib/events/encryptedevent.cpp | 12 | ||||
-rw-r--r-- | lib/jobs/downloadfilejob.cpp | 2 |
4 files changed, 8 insertions, 11 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp index a7af1477..ac428a62 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -56,7 +56,6 @@ #include <QtCore/QStringBuilder> #include <QtNetwork/QDnsLookup> - #if QT_VERSION_MAJOR >= 6 # include <qt6keychain/keychain.h> #else @@ -1948,7 +1947,7 @@ void Connection::Private::saveDevicesList() QElapsedTimer et; et.start(); - QFile outFile { q->e2eeDataDir() + QStringLiteral("/deviceslist.json") }; + QFile outFile { q->e2eeDataDir() % "/deviceslist.json" }; if (!outFile.open(QFile::WriteOnly)) { qCWarning(E2EE) << "Error opening" << outFile.fileName() << ":" << outFile.errorString(); diff --git a/lib/encryptionmanager.cpp b/lib/encryptionmanager.cpp index ed6ad20b..5c106e12 100644 --- a/lib/encryptionmanager.cpp +++ b/lib/encryptionmanager.cpp @@ -80,7 +80,7 @@ public: } } void saveSessions() { - QFile outFile { static_cast<Connection *>(q->parent())->e2eeDataDir() + QStringLiteral("/olmsessions.json") }; + QFile outFile { static_cast<Connection *>(q->parent())->e2eeDataDir() % "/olmsessions.json" }; if (!outFile.open(QFile::WriteOnly)) { qCWarning(E2EE) << "Error opening" << outFile.fileName() << ":" << outFile.errorString(); diff --git a/lib/events/encryptedevent.cpp b/lib/events/encryptedevent.cpp index c9257584..2e0d7387 100644 --- a/lib/events/encryptedevent.cpp +++ b/lib/events/encryptedevent.cpp @@ -38,17 +38,15 @@ RoomEventPtr EncryptedEvent::createDecrypted(const QString &decrypted) const 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(); + if (const auto relatesToJson = contentPart("m.relates_to"_ls); !relatesToJson.isUndefined()) { auto content = eventObject["content"].toObject(); - content["m.relates_to"] = relates; + content["m.relates_to"] = relatesToJson.toObject(); eventObject["content"] = content; } - if(unsignedJson().contains("redacts")) { - auto redacts = unsignedJson()["redacts"].toString(); + if (const auto redactsJson = unsignedPart("redacts"_ls); !redactsJson.isUndefined()) { auto unsign = eventObject["unsigned"].toObject(); - unsign["redacts"] = redacts; + unsign["redacts"] = redactsJson.toString(); eventObject["unsigned"] = unsign; } - return makeEvent<RoomMessageEvent>(eventObject); + return loadEvent<RoomEvent>(eventObject); } diff --git a/lib/jobs/downloadfilejob.cpp b/lib/jobs/downloadfilejob.cpp index 0b4cf6d2..2eea9d59 100644 --- a/lib/jobs/downloadfilejob.cpp +++ b/lib/jobs/downloadfilejob.cpp @@ -8,7 +8,7 @@ #include <QtNetwork/QNetworkReply> #ifdef Quotient_E2EE_ENABLED -# include <QCryptographicHash> +# include <QtCore/QCryptographicHash> # include "encryptionmanager.h" # include "events/encryptedfile.h" #endif |