| 1 | // SPDX-FileCopyrightText: 2019 Kitsune Ral <Kitsune-Ral@users.sf.net> |
|---|---|
| 2 | // SPDX-License-Identifier: LGPL-2.1-or-later |
| 3 | |
| 4 | #include "roomcreateevent.h" |
| 5 | |
| 6 | using namespace Quotient; |
| 7 | |
| 8 | template <> |
| 9 | RoomType Quotient::fromJson(const QJsonValue& jv) |
| 10 | { |
| 11 | return enumFromJsonString(s: jv.toString(), enumValues: RoomTypeStrings, |
| 12 | defaultValue: RoomType::Undefined); |
| 13 | } |
| 14 | |
| 15 | bool RoomCreateEvent::isFederated() const |
| 16 | { |
| 17 | return contentPart<bool>(key: "m.federate"_ls); |
| 18 | } |
| 19 | |
| 20 | QString RoomCreateEvent::version() const |
| 21 | { |
| 22 | return contentPart<QString>(key: "room_version"_ls); |
| 23 | } |
| 24 | |
| 25 | RoomCreateEvent::Predecessor RoomCreateEvent::predecessor() const |
| 26 | { |
| 27 | const auto predJson = contentPart<QJsonObject>(key: "predecessor"_ls); |
| 28 | return { .roomId: fromJson<QString>(jv: predJson[RoomIdKey]), |
| 29 | .eventId: fromJson<QString>(jv: predJson[EventIdKey]) }; |
| 30 | } |
| 31 | |
| 32 | bool RoomCreateEvent::isUpgrade() const |
| 33 | { |
| 34 | return contentJson().contains(key: "predecessor"_ls); |
| 35 | } |
| 36 | |
| 37 | RoomType RoomCreateEvent::roomType() const |
| 38 | { |
| 39 | return contentPart<RoomType>(key: "type"_ls); |
| 40 | } |
| 41 |