diff options
author | Josip Delic <delijati@googlemail.com> | 2018-08-29 21:56:21 +0200 |
---|---|---|
committer | Josip Delic <delijati@googlemail.com> | 2018-08-29 21:56:21 +0200 |
commit | 6bb64db38f4a5f47d275a663861fd216f1bcf612 (patch) | |
tree | cf92c21991282852e2ae549cd950984a7ae64fc6 /lib/csapi/list_public_rooms.cpp | |
parent | 8d07a6bec2689a81c3c3db64e5457143bd671223 (diff) | |
parent | d9ff200ff62fb7f5b6b51082dc3979d5454a1bec (diff) | |
download | libquotient-6bb64db38f4a5f47d275a663861fd216f1bcf612.tar.gz libquotient-6bb64db38f4a5f47d275a663861fd216f1bcf612.zip |
Merge branch 'master' of https://github.com/QMatrixClient/libqmatrixclient
Diffstat (limited to 'lib/csapi/list_public_rooms.cpp')
-rw-r--r-- | lib/csapi/list_public_rooms.cpp | 67 |
1 files changed, 6 insertions, 61 deletions
diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp index c34af34c..1a5b9203 100644 --- a/lib/csapi/list_public_rooms.cpp +++ b/lib/csapi/list_public_rooms.cpp @@ -58,47 +58,10 @@ SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString& setRequestData(_data); } -namespace QMatrixClient -{ - // Converters - - template <> struct FromJson<GetPublicRoomsJob::PublicRoomsChunk> - { - GetPublicRoomsJob::PublicRoomsChunk operator()(const QJsonValue& jv) - { - const auto& _json = jv.toObject(); - GetPublicRoomsJob::PublicRoomsChunk result; - result.aliases = - fromJson<QStringList>(_json.value("aliases"_ls)); - result.canonicalAlias = - fromJson<QString>(_json.value("canonical_alias"_ls)); - result.name = - fromJson<QString>(_json.value("name"_ls)); - result.numJoinedMembers = - fromJson<qint64>(_json.value("num_joined_members"_ls)); - result.roomId = - fromJson<QString>(_json.value("room_id"_ls)); - result.topic = - fromJson<QString>(_json.value("topic"_ls)); - result.worldReadable = - fromJson<bool>(_json.value("world_readable"_ls)); - result.guestCanJoin = - fromJson<bool>(_json.value("guest_can_join"_ls)); - result.avatarUrl = - fromJson<QString>(_json.value("avatar_url"_ls)); - - return result; - } - }; -} // namespace QMatrixClient - class GetPublicRoomsJob::Private { public: - QVector<PublicRoomsChunk> chunk; - QString nextBatch; - QString prevBatch; - Omittable<qint64> totalRoomCountEstimate; + PublicRoomsResponse data; }; BaseJob::Query queryToGetPublicRooms(Omittable<int> limit, const QString& since, const QString& server) @@ -130,36 +93,18 @@ GetPublicRoomsJob::GetPublicRoomsJob(Omittable<int> limit, const QString& since, GetPublicRoomsJob::~GetPublicRoomsJob() = default; -const QVector<GetPublicRoomsJob::PublicRoomsChunk>& GetPublicRoomsJob::chunk() const +const PublicRoomsResponse& GetPublicRoomsJob::data() const { - return d->chunk; -} - -const QString& GetPublicRoomsJob::nextBatch() const -{ - return d->nextBatch; -} - -const QString& GetPublicRoomsJob::prevBatch() const -{ - return d->prevBatch; -} - -Omittable<qint64> GetPublicRoomsJob::totalRoomCountEstimate() const -{ - return d->totalRoomCountEstimate; + return d->data; } BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data) { auto json = data.object(); - if (!json.contains("chunk"_ls)) + if (!json.contains("data"_ls)) return { JsonParseError, - "The key 'chunk' not found in the response" }; - d->chunk = fromJson<QVector<PublicRoomsChunk>>(json.value("chunk"_ls)); - d->nextBatch = fromJson<QString>(json.value("next_batch"_ls)); - d->prevBatch = fromJson<QString>(json.value("prev_batch"_ls)); - d->totalRoomCountEstimate = fromJson<qint64>(json.value("total_room_count_estimate"_ls)); + "The key 'data' not found in the response" }; + d->data = fromJson<PublicRoomsResponse>(json.value("data"_ls)); return Success; } |