From e17764a1ae81393968dfb747c7b67353c109bc71 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Fri, 19 Jun 2020 15:01:33 +0200 Subject: csapi/: generated using the latest GTAD and matrix-doc For matrix-doc, specifically, it is master (5cb4b086) merged with https://github.com/matrix-org/matrix-doc/pull/2518. --- lib/csapi/list_public_rooms.h | 71 ++++++++++++------------------------------- 1 file changed, 20 insertions(+), 51 deletions(-) (limited to 'lib/csapi/list_public_rooms.h') diff --git a/lib/csapi/list_public_rooms.h b/lib/csapi/list_public_rooms.h index 5ef7c23e..b0cb79d2 100644 --- a/lib/csapi/list_public_rooms.h +++ b/lib/csapi/list_public_rooms.h @@ -17,7 +17,6 @@ namespace Quotient { class GetRoomVisibilityOnDirectoryJob : public BaseJob { public: /*! \brief Gets the visibility of a room in the directory - * * * \param roomId * The room ID. @@ -52,7 +51,6 @@ public: class SetRoomVisibilityOnDirectoryJob : public BaseJob { public: /*! \brief Sets the visibility of a room in the room directory - * * * \param roomId * The room ID. @@ -75,7 +73,6 @@ public: class GetPublicRoomsJob : public BaseJob { public: /*! \brief Lists the public rooms on the server. - * * * \param limit * Limit the number of results returned. @@ -105,10 +102,27 @@ public: // Result properties - /// A list of the rooms on the server. - PublicRoomsResponse data() const + /// A paginated chunk of public rooms. + QVector chunk() const { - return fromJson(jsonData()); + return loadFromJson>("chunk"_ls); + } + + /// A pagination token for the response. The absence of this token + /// means there are no more results to fetch and the client should + /// stop paginating. + QString nextBatch() const { return loadFromJson("next_batch"_ls); } + + /// A pagination token that allows fetching previous results. The + /// absence of this token means there are no results before this + /// batch, i.e. this is the first batch. + QString prevBatch() const { return loadFromJson("prev_batch"_ls); } + + /// An estimate on the total number of public rooms, if the + /// server has an estimate. + Omittable totalRoomCountEstimate() const + { + return loadFromJson>("total_room_count_estimate"_ls); } }; @@ -130,37 +144,9 @@ public: QString genericSearchTerm; }; - /// Lists the public rooms on the server, with optional filter. - /// - /// This API returns paginated responses. The rooms are ordered by the - /// number of joined members, with the largest rooms first. - struct PublicRoomsChunk { - /// Aliases of the room. May be empty. - QStringList aliases; - /// The canonical alias of the room, if any. - QString canonicalAlias; - /// The name of the room, if any. - QString name; - /// The number of members joined to the room. - int numJoinedMembers; - /// The ID of the room. - QString roomId; - /// The topic of the room, if any. - QString topic; - /// Whether the room may be viewed by guest users without joining. - bool worldReadable; - /// Whether guest users may join the room and participate in it. - /// If they can, they will be subject to ordinary power level - /// rules like any other user. - bool guestCanJoin; - /// The URL for the room's avatar, if one is set. - QString avatarUrl; - }; - // Construction/destruction /*! \brief Lists the public rooms on the server with optional filter. - * * * \param server * The server to fetch the public room lists from. Defaults to the @@ -228,21 +214,4 @@ struct JsonObjectConverter { } }; -template <> -struct JsonObjectConverter { - static void fillFrom(const QJsonObject& jo, - QueryPublicRoomsJob::PublicRoomsChunk& result) - { - fromJson(jo.value("aliases"_ls), result.aliases); - fromJson(jo.value("canonical_alias"_ls), result.canonicalAlias); - fromJson(jo.value("name"_ls), result.name); - fromJson(jo.value("num_joined_members"_ls), result.numJoinedMembers); - fromJson(jo.value("room_id"_ls), result.roomId); - fromJson(jo.value("topic"_ls), result.topic); - fromJson(jo.value("world_readable"_ls), result.worldReadable); - fromJson(jo.value("guest_can_join"_ls), result.guestCanJoin); - fromJson(jo.value("avatar_url"_ls), result.avatarUrl); - } -}; - } // namespace Quotient -- cgit v1.2.3