aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/list_public_rooms.cpp
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/list_public_rooms.cpp
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'lib/csapi/list_public_rooms.cpp')
-rw-r--r--lib/csapi/list_public_rooms.cpp164
1 files changed, 48 insertions, 116 deletions
diff --git a/lib/csapi/list_public_rooms.cpp b/lib/csapi/list_public_rooms.cpp
index 71b3c541..415d816c 100644
--- a/lib/csapi/list_public_rooms.cpp
+++ b/lib/csapi/list_public_rooms.cpp
@@ -4,67 +4,39 @@
#include "list_public_rooms.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
+using namespace Quotient;
-class GetRoomVisibilityOnDirectoryJob::Private
-{
- public:
- QString visibility;
-};
-
-QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl, const QString& roomId)
+QUrl GetRoomVisibilityOnDirectoryJob::makeRequestUrl(QUrl baseUrl,
+ const QString& roomId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/directory/list/room/" % roomId);
-}
-
-static const auto GetRoomVisibilityOnDirectoryJobName = QStringLiteral("GetRoomVisibilityOnDirectoryJob");
-
-GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob(const QString& roomId)
- : BaseJob(HttpVerb::Get, GetRoomVisibilityOnDirectoryJobName,
- basePath % "/directory/list/room/" % roomId, false)
- , d(new Private)
-{
-}
-
-GetRoomVisibilityOnDirectoryJob::~GetRoomVisibilityOnDirectoryJob() = default;
-
-const QString& GetRoomVisibilityOnDirectoryJob::visibility() const
-{
- return d->visibility;
-}
-
-BaseJob::Status GetRoomVisibilityOnDirectoryJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- fromJson(json.value("visibility"_ls), d->visibility);
- return Success;
+ QStringLiteral("/_matrix/client/r0")
+ % "/directory/list/room/" % roomId);
}
-static const auto SetRoomVisibilityOnDirectoryJobName = QStringLiteral("SetRoomVisibilityOnDirectoryJob");
+GetRoomVisibilityOnDirectoryJob::GetRoomVisibilityOnDirectoryJob(
+ const QString& roomId)
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomVisibilityOnDirectoryJob"),
+ QStringLiteral("/_matrix/client/r0") % "/directory/list/room/"
+ % roomId,
+ false)
+{}
-SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(const QString& roomId, const QString& visibility)
- : BaseJob(HttpVerb::Put, SetRoomVisibilityOnDirectoryJobName,
- basePath % "/directory/list/room/" % roomId)
+SetRoomVisibilityOnDirectoryJob::SetRoomVisibilityOnDirectoryJob(
+ const QString& roomId, const QString& visibility)
+ : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomVisibilityOnDirectoryJob"),
+ QStringLiteral("/_matrix/client/r0") % "/directory/list/room/"
+ % roomId)
{
QJsonObject _data;
addParam<IfNotEmpty>(_data, QStringLiteral("visibility"), visibility);
- setRequestData(_data);
+ setRequestData(std::move(_data));
}
-class GetPublicRoomsJob::Private
-{
- public:
- PublicRoomsResponse data;
-};
-
-BaseJob::Query queryToGetPublicRooms(Omittable<int> limit, const QString& since, const QString& server)
+auto queryToGetPublicRooms(Omittable<int> limit, const QString& since,
+ const QString& server)
{
BaseJob::Query _q;
addParam<IfNotEmpty>(_q, QStringLiteral("limit"), limit);
@@ -73,90 +45,50 @@ BaseJob::Query queryToGetPublicRooms(Omittable<int> limit, const QString& since,
return _q;
}
-QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable<int> limit, const QString& since, const QString& server)
+QUrl GetPublicRoomsJob::makeRequestUrl(QUrl baseUrl, Omittable<int> limit,
+ const QString& since,
+ const QString& server)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/publicRooms",
- queryToGetPublicRooms(limit, since, server));
+ QStringLiteral("/_matrix/client/r0")
+ % "/publicRooms",
+ queryToGetPublicRooms(limit, since, server));
}
-static const auto GetPublicRoomsJobName = QStringLiteral("GetPublicRoomsJob");
-
-GetPublicRoomsJob::GetPublicRoomsJob(Omittable<int> limit, const QString& since, const QString& server)
- : BaseJob(HttpVerb::Get, GetPublicRoomsJobName,
- basePath % "/publicRooms",
- queryToGetPublicRooms(limit, since, server),
- {}, false)
- , d(new Private)
+GetPublicRoomsJob::GetPublicRoomsJob(Omittable<int> limit, const QString& since,
+ const QString& server)
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetPublicRoomsJob"),
+ QStringLiteral("/_matrix/client/r0") % "/publicRooms",
+ queryToGetPublicRooms(limit, since, server), {}, false)
{
+ addExpectedKey("chunk");
}
-GetPublicRoomsJob::~GetPublicRoomsJob() = default;
-
-const PublicRoomsResponse& GetPublicRoomsJob::data() const
-{
- return d->data;
-}
-
-BaseJob::Status GetPublicRoomsJob::parseJson(const QJsonDocument& data)
-{
- fromJson(data, d->data);
- return Success;
-}
-
-namespace QMatrixClient
-{
- // Converters
-
- template <> struct JsonObjectConverter<QueryPublicRoomsJob::Filter>
- {
- static void dumpTo(QJsonObject& jo, const QueryPublicRoomsJob::Filter& pod)
- {
- addParam<IfNotEmpty>(jo, QStringLiteral("generic_search_term"), pod.genericSearchTerm);
- }
- };
-} // namespace QMatrixClient
-
-class QueryPublicRoomsJob::Private
-{
- public:
- PublicRoomsResponse data;
-};
-
-BaseJob::Query queryToQueryPublicRooms(const QString& server)
+auto queryToQueryPublicRooms(const QString& server)
{
BaseJob::Query _q;
addParam<IfNotEmpty>(_q, QStringLiteral("server"), server);
return _q;
}
-static const auto QueryPublicRoomsJobName = QStringLiteral("QueryPublicRoomsJob");
-
-QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server, Omittable<int> limit, const QString& since, const Omittable<Filter>& filter, Omittable<bool> includeAllNetworks, const QString& thirdPartyInstanceId)
- : BaseJob(HttpVerb::Post, QueryPublicRoomsJobName,
- basePath % "/publicRooms",
- queryToQueryPublicRooms(server))
- , d(new Private)
+QueryPublicRoomsJob::QueryPublicRoomsJob(const QString& server,
+ Omittable<int> limit,
+ const QString& since,
+ const Omittable<Filter>& filter,
+ Omittable<bool> includeAllNetworks,
+ const QString& thirdPartyInstanceId)
+ : BaseJob(HttpVerb::Post, QStringLiteral("QueryPublicRoomsJob"),
+ QStringLiteral("/_matrix/client/r0") % "/publicRooms",
+ queryToQueryPublicRooms(server))
{
QJsonObject _data;
addParam<IfNotEmpty>(_data, QStringLiteral("limit"), limit);
addParam<IfNotEmpty>(_data, QStringLiteral("since"), since);
addParam<IfNotEmpty>(_data, QStringLiteral("filter"), filter);
- addParam<IfNotEmpty>(_data, QStringLiteral("include_all_networks"), includeAllNetworks);
- addParam<IfNotEmpty>(_data, QStringLiteral("third_party_instance_id"), thirdPartyInstanceId);
- setRequestData(_data);
-}
-
-QueryPublicRoomsJob::~QueryPublicRoomsJob() = default;
-
-const PublicRoomsResponse& QueryPublicRoomsJob::data() const
-{
- return d->data;
+ addParam<IfNotEmpty>(_data, QStringLiteral("include_all_networks"),
+ includeAllNetworks);
+ addParam<IfNotEmpty>(_data, QStringLiteral("third_party_instance_id"),
+ thirdPartyInstanceId);
+ setRequestData(std::move(_data));
+ addExpectedKey("chunk");
}
-
-BaseJob::Status QueryPublicRoomsJob::parseJson(const QJsonDocument& data)
-{
- fromJson(data, d->data);
- return Success;
-}
-