5 #include <Quotient/csapi/definitions/public_rooms_response.h>
7 #include <Quotient/jobs/basejob.h>
14 class QUOTIENT_API GetRoomVisibilityOnDirectoryJob :
public BaseJob {
18 explicit GetRoomVisibilityOnDirectoryJob(
const QString& roomId);
24 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& roomId);
29 QString visibility()
const {
return loadFromJson<QString>(
"visibility"_L1); }
32 inline auto collectResponse(
const GetRoomVisibilityOnDirectoryJob* job)
34 return job->visibility();
45 class QUOTIENT_API SetRoomVisibilityOnDirectoryJob :
public BaseJob {
53 explicit SetRoomVisibilityOnDirectoryJob(
const QString& roomId,
const QString& visibility = {});
76 explicit GetPublicRoomsJob(std::optional<
int> limit = std::nullopt,
const QString& since = {},
77 const QString& server = {});
83 static QUrl makeRequestUrl(
const HomeserverData& hsData, std::optional<
int> limit = std::nullopt,
84 const QString& since = {},
const QString& server = {});
89 QVector<PublicRoomsChunk> chunk()
const
91 return loadFromJson<QVector<PublicRoomsChunk>>(
"chunk"_L1);
97 QString nextBatch()
const {
return loadFromJson<QString>(
"next_batch"_L1); }
102 QString prevBatch()
const {
return loadFromJson<QString>(
"prev_batch"_L1); }
106 std::optional<
int> totalRoomCountEstimate()
const
108 return loadFromJson<std::optional<
int>>(
"total_room_count_estimate"_L1);
113 QVector<PublicRoomsChunk> chunk{};
127 std::optional<
int> totalRoomCountEstimate{};
131 template <std::derived_from<GetPublicRoomsJob> JobT>
132 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> GetPublicRoomsJob::Response {
133 return { j->chunk(), j->nextBatch(), j->prevBatch(), j->totalRoomCountEstimate() };
150 QString genericSearchTerm{};
156 QStringList roomTypes{};
184 explicit QueryPublicRoomsJob(
const QString& server = {},
185 std::optional<
int> limit = std::nullopt,
const QString& since = {},
186 const std::optional<Filter>& filter = std::nullopt,
187 std::optional<
bool> includeAllNetworks = std::nullopt,
188 const QString& thirdPartyInstanceId = {});
193 QVector<PublicRoomsChunk> chunk()
const
195 return loadFromJson<QVector<PublicRoomsChunk>>(
"chunk"_L1);
201 QString nextBatch()
const {
return loadFromJson<QString>(
"next_batch"_L1); }
206 QString prevBatch()
const {
return loadFromJson<QString>(
"prev_batch"_L1); }
210 std::optional<
int> totalRoomCountEstimate()
const
212 return loadFromJson<std::optional<
int>>(
"total_room_count_estimate"_L1);
217 QVector<PublicRoomsChunk> chunk{};
231 std::optional<
int> totalRoomCountEstimate{};
235 template <std::derived_from<QueryPublicRoomsJob> JobT>
236 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> QueryPublicRoomsJob::Response {
237 return { j->chunk(), j->nextBatch(), j->prevBatch(), j->totalRoomCountEstimate() };
241 struct QUOTIENT_API JsonObjectConverter<QueryPublicRoomsJob::Filter> {
242 static void dumpTo(QJsonObject& jo,
const QueryPublicRoomsJob::Filter& pod)
244 addParam<IfNotEmpty>(jo,
"generic_search_term"_L1, pod.genericSearchTerm);
245 addParam<IfNotEmpty>(jo,
"room_types"_L1, pod.roomTypes);