aboutsummaryrefslogtreecommitdiff
path: root/lib/events/stateevent.cpp
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-12-22 16:13:02 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2021-12-22 16:13:02 +0100
commit060af9334049c58767b6457da2d7c07fdb0d171e (patch)
tree8f44541cd883d94267a1c31ce4145e69f750798a /lib/events/stateevent.cpp
parent231c4d723eb53f3ea5f641b743d198584840a963 (diff)
downloadlibquotient-060af9334049c58767b6457da2d7c07fdb0d171e.tar.gz
libquotient-060af9334049c58767b6457da2d7c07fdb0d171e.zip
StateEventBase: force type to unknown if stateKey is not in JSON
Diffstat (limited to 'lib/events/stateevent.cpp')
-rw-r--r--lib/events/stateevent.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/events/stateevent.cpp b/lib/events/stateevent.cpp
index 9535af56..e53d47d4 100644
--- a/lib/events/stateevent.cpp
+++ b/lib/events/stateevent.cpp
@@ -5,6 +5,14 @@
using namespace Quotient;
+StateEventBase::StateEventBase(Type type, const QJsonObject& json)
+ : RoomEvent(json.contains(StateKeyKeyL) ? type : unknownEventTypeId(), json)
+{
+ if (Event::type() == unknownEventTypeId() && !json.contains(StateKeyKeyL))
+ qWarning(EVENTS) << "Attempt to create a state event with no stateKey -"
+ "forcing the event type to unknown to avoid damage";
+}
+
StateEventBase::StateEventBase(Event::Type type, event_mtype_t matrixType,
const QString& stateKey,
const QJsonObject& contentJson)