diff options
author | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-02-15 20:51:32 +0100 |
---|---|---|
committer | Alexey Rusakov <Kitsune-Ral@users.sf.net> | 2022-02-16 17:58:17 +0100 |
commit | 53dfa70601b2d27a6be12d52e86af123d0b26b79 (patch) | |
tree | a8629e4a229edfeec7c5f32ab72db7d63dc1ed06 /lib/events/encryptedevent.cpp | |
parent | 52a787eefb3fb3d147648d08fc439a4b8a966fd3 (diff) | |
download | libquotient-53dfa70601b2d27a6be12d52e86af123d0b26b79.tar.gz libquotient-53dfa70601b2d27a6be12d52e86af123d0b26b79.zip |
Cleanup
A note on switching to QLatin1String for JSON key constants - this is
more concise and barely affects (if at all) runtime performance (padding
each QChar with zeros is trivial for assignment; and comparison can be
done directly with the same performance as for two QStrings).
Diffstat (limited to 'lib/events/encryptedevent.cpp')
-rw-r--r-- | lib/events/encryptedevent.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/events/encryptedevent.cpp b/lib/events/encryptedevent.cpp index 1b5e4441..ba4dd154 100644 --- a/lib/events/encryptedevent.cpp +++ b/lib/events/encryptedevent.cpp @@ -33,6 +33,19 @@ EncryptedEvent::EncryptedEvent(const QJsonObject& obj) qCDebug(E2EE) << "Encrypted event from" << senderId(); } +QString EncryptedEvent::algorithm() const +{ + auto algo = contentPart<QString>(AlgorithmKeyL); + static constexpr auto SupportedAlgorithms = + make_array(OlmV1Curve25519AesSha2AlgoKey, MegolmV1AesSha2AlgoKey); + if (std::find(SupportedAlgorithms.cbegin(), SupportedAlgorithms.cend(), + algo) == SupportedAlgorithms.cend()) { + qWarning(MAIN) << "The EncryptedEvent's algorithm" << algo + << "is not supported"; + } + return algo; +} + RoomEventPtr EncryptedEvent::createDecrypted(const QString &decrypted) const { auto eventObject = QJsonDocument::fromJson(decrypted.toUtf8()).object(); |