aboutsummaryrefslogtreecommitdiff
path: root/lib/events/encryptionevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-11-19 14:56:09 +0100
committerKitsune Ral <Kitsune-Ral@users.sf.net>2020-11-19 14:59:14 +0100
commitdda813899fdb4a520dc83e10c17c1923712a8f7d (patch)
treeb685f8e5cb52c220ae0ffb19c7fbace47f2fab9c /lib/events/encryptionevent.cpp
parent52cab4b11bdd48cd87e04c01b12c698ec4145e6d (diff)
downloadlibquotient-dda813899fdb4a520dc83e10c17c1923712a8f7d.tar.gz
libquotient-dda813899fdb4a520dc83e10c17c1923712a8f7d.zip
Fix Q_ASSERT failure on sending messages
Changes in e81117fb exposed a flaw in EncryptionEvent causing assertion failure when this event is default-initialised (i.e. no encryption).
Diffstat (limited to 'lib/events/encryptionevent.cpp')
-rw-r--r--lib/events/encryptionevent.cpp19
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/events/encryptionevent.cpp b/lib/events/encryptionevent.cpp
index 073303b0..f1bde621 100644
--- a/lib/events/encryptionevent.cpp
+++ b/lib/events/encryptionevent.cpp
@@ -1,21 +1,14 @@
-//
-// Created by rusakov on 26/09/2017.
-// Contributed by andreev on 27/06/2019.
-//
-
#include "encryptionevent.h"
-#include "converters.h"
#include "e2ee.h"
-#include "logging.h"
#include <array>
+namespace Quotient {
static const std::array<QString, 1> encryptionStrings = {
- { Quotient::MegolmV1AesSha2AlgoKey }
+ { MegolmV1AesSha2AlgoKey }
};
-namespace Quotient {
template <>
struct JsonConverter<EncryptionType> {
static EncryptionType load(const QJsonValue& jv)
@@ -26,7 +19,8 @@ struct JsonConverter<EncryptionType> {
if (encryptionString == *it)
return EncryptionType(it - encryptionStrings.begin());
- qCWarning(EVENTS) << "Unknown EncryptionType: " << encryptionString;
+ if (!encryptionString.isEmpty())
+ qCWarning(EVENTS) << "Unknown EncryptionType: " << encryptionString;
return EncryptionType::Undefined;
}
};
@@ -35,7 +29,7 @@ struct JsonConverter<EncryptionType> {
using namespace Quotient;
EncryptionEventContent::EncryptionEventContent(const QJsonObject& json)
- : encryption(fromJson<EncryptionType>(json["algorithm"_ls]))
+ : encryption(fromJson<EncryptionType>(json[AlgorithmKeyL]))
, algorithm(sanitized(json[AlgorithmKeyL].toString()))
, rotationPeriodMs(json[RotationPeriodMsKeyL].toInt(604800000))
, rotationPeriodMsgs(json[RotationPeriodMsgsKeyL].toInt(100))
@@ -44,9 +38,6 @@ EncryptionEventContent::EncryptionEventContent(const QJsonObject& json)
void EncryptionEventContent::fillJson(QJsonObject* o) const
{
Q_ASSERT(o);
- Q_ASSERT_X(
- encryption != EncryptionType::Undefined, __FUNCTION__,
- "The key 'algorithm' must be explicit in EncryptionEventContent");
if (encryption != EncryptionType::Undefined)
o->insert(AlgorithmKey, algorithm);
o->insert(RotationPeriodMsKey, rotationPeriodMs);