aboutsummaryrefslogtreecommitdiff
path: root/lib/events/roomcreateevent.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-15 11:11:47 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2019-02-15 11:11:47 +0900
commit6af5e93134065cd97644d2eee43b2852df549553 (patch)
treee2c6b1375a97f5b50381e23fd47eeae2f46d73db /lib/events/roomcreateevent.cpp
parenta8adbc1d3c8ba787321ebd558062a9c12b12324a (diff)
downloadlibquotient-6af5e93134065cd97644d2eee43b2852df549553.tar.gz
libquotient-6af5e93134065cd97644d2eee43b2852df549553.zip
Simplify RoomCreateEvent
Diffstat (limited to 'lib/events/roomcreateevent.cpp')
-rw-r--r--lib/events/roomcreateevent.cpp29
1 files changed, 18 insertions, 11 deletions
diff --git a/lib/events/roomcreateevent.cpp b/lib/events/roomcreateevent.cpp
index 635efb92..8fd0f1de 100644
--- a/lib/events/roomcreateevent.cpp
+++ b/lib/events/roomcreateevent.cpp
@@ -20,19 +20,26 @@
using namespace QMatrixClient;
-RoomCreateDetails::RoomCreateDetails(const QJsonObject& json)
- : federated(fromJson<bool>(json["m.federate"_ls]))
- , version(fromJson<QString>(json["room_version"_ls]))
+bool RoomCreateEvent::isFederated() const
{
- const auto predecessorJson = json["predecessor"_ls].toObject();
- if (!predecessorJson.isEmpty())
- {
- fromJson(predecessorJson["room_id"_ls], predRoomId);
- fromJson(predecessorJson["event_id"_ls], predEventId);
- }
+ return fromJson<bool>(contentJson()["m.federate"_ls]);
}
-std::pair<QString, QString> RoomCreateEvent::predecessor() const
+QString RoomCreateEvent::version() const
{
- return { content().predRoomId, content().predEventId };
+ return fromJson<QString>(contentJson()["room_version"_ls]);
+}
+
+RoomCreateEvent::Predecessor RoomCreateEvent::predecessor() const
+{
+ const auto predJson = contentJson()["predecessor"_ls].toObject();
+ return {
+ fromJson<QString>(predJson["room_id"_ls]),
+ fromJson<QString>(predJson["event_id"_ls])
+ };
+}
+
+bool RoomCreateEvent::isUpgrade() const
+{
+ return contentJson().contains("predecessor"_ls);
}