aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roomcreateevent.cpp
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
committern-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
commitd911b207f49e936b3e992200796110f0749ed150 (patch)
tree96d20ebb4d074a4c1755e21cb316a52d584daee3 /lib/events/roomcreateevent.cpp
parent8ad8a74152c5701b6ca1f9a00487ba9257a439b4 (diff)
parent56c2f2e2b809b9077393eb617828f33d144f5634 (diff)
downloadlibquotient-d911b207f49e936b3e992200796110f0749ed150.tar.gz
libquotient-d911b207f49e936b3e992200796110f0749ed150.zip
New upstream version 0.7.0
Diffstat (limited to 'lib/events/roomcreateevent.cpp')
-rw-r--r--lib/events/roomcreateevent.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/events/roomcreateevent.cpp b/lib/events/roomcreateevent.cpp
new file mode 100644
index 00000000..3b5024d5
--- /dev/null
+++ b/lib/events/roomcreateevent.cpp
@@ -0,0 +1,40 @@
+// SPDX-FileCopyrightText: 2019 Kitsune Ral <Kitsune-Ral@users.sf.net>
+// SPDX-License-Identifier: LGPL-2.1-or-later
+
+#include "roomcreateevent.h"
+
+using namespace Quotient;
+
+template <>
+RoomType Quotient::fromJson(const QJsonValue& jv)
+{
+ return enumFromJsonString(jv.toString(), RoomTypeStrings,
+ RoomType::Undefined);
+}
+
+bool RoomCreateEvent::isFederated() const
+{
+ return contentPart<bool>("m.federate"_ls);
+}
+
+QString RoomCreateEvent::version() const
+{
+ return contentPart<QString>("room_version"_ls);
+}
+
+RoomCreateEvent::Predecessor RoomCreateEvent::predecessor() const
+{
+ const auto predJson = contentPart<QJsonObject>("predecessor"_ls);
+ return { fromJson<QString>(predJson[RoomIdKeyL]),
+ fromJson<QString>(predJson[EventIdKeyL]) };
+}
+
+bool RoomCreateEvent::isUpgrade() const
+{
+ return contentJson().contains("predecessor"_ls);
+}
+
+RoomType RoomCreateEvent::roomType() const
+{
+ return contentPart<RoomType>("type"_ls);
+}