aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/message_pagination.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/message_pagination.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/message_pagination.cpp')
-rw-r--r--lib/csapi/message_pagination.cpp74
1 files changed, 20 insertions, 54 deletions
diff --git a/lib/csapi/message_pagination.cpp b/lib/csapi/message_pagination.cpp
index 9aca7ec9..855c051f 100644
--- a/lib/csapi/message_pagination.cpp
+++ b/lib/csapi/message_pagination.cpp
@@ -4,23 +4,13 @@
#include "message_pagination.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class GetRoomEventsJob::Private
-{
- public:
- QString begin;
- QString end;
- RoomEvents chunk;
-};
+using namespace Quotient;
-BaseJob::Query queryToGetRoomEvents(const QString& from, const QString& to, const QString& dir, Omittable<int> limit, const QString& filter)
+auto queryToGetRoomEvents(const QString& from, const QString& to,
+ const QString& dir, Omittable<int> limit,
+ const QString& filter)
{
BaseJob::Query _q;
addParam<>(_q, QStringLiteral("from"), from);
@@ -31,46 +21,22 @@ BaseJob::Query queryToGetRoomEvents(const QString& from, const QString& to, cons
return _q;
}
-QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& from, const QString& dir, const QString& to, Omittable<int> limit, const QString& filter)
-{
- return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/rooms/" % roomId % "/messages",
- queryToGetRoomEvents(from, to, dir, limit, filter));
-}
-
-static const auto GetRoomEventsJobName = QStringLiteral("GetRoomEventsJob");
-
-GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from, const QString& dir, const QString& to, Omittable<int> limit, const QString& filter)
- : BaseJob(HttpVerb::Get, GetRoomEventsJobName,
- basePath % "/rooms/" % roomId % "/messages",
- queryToGetRoomEvents(from, to, dir, limit, filter))
- , d(new Private)
-{
-}
-
-GetRoomEventsJob::~GetRoomEventsJob() = default;
-
-const QString& GetRoomEventsJob::begin() const
-{
- return d->begin;
-}
-
-const QString& GetRoomEventsJob::end() const
-{
- return d->end;
-}
-
-RoomEvents&& GetRoomEventsJob::chunk()
-{
- return std::move(d->chunk);
-}
-
-BaseJob::Status GetRoomEventsJob::parseJson(const QJsonDocument& data)
+QUrl GetRoomEventsJob::makeRequestUrl(QUrl baseUrl, const QString& roomId,
+ const QString& from, const QString& dir,
+ const QString& to, Omittable<int> limit,
+ const QString& filter)
{
- auto json = data.object();
- fromJson(json.value("start"_ls), d->begin);
- fromJson(json.value("end"_ls), d->end);
- fromJson(json.value("chunk"_ls), d->chunk);
- return Success;
+ return BaseJob::makeRequestUrl(
+ std::move(baseUrl),
+ QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId % "/messages",
+ queryToGetRoomEvents(from, to, dir, limit, filter));
}
+GetRoomEventsJob::GetRoomEventsJob(const QString& roomId, const QString& from,
+ const QString& dir, const QString& to,
+ Omittable<int> limit, const QString& filter)
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetRoomEventsJob"),
+ QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId
+ % "/messages",
+ queryToGetRoomEvents(from, to, dir, limit, filter))
+{}