aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/peeking_events.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/peeking_events.cpp')
-rw-r--r--lib/csapi/peeking_events.cpp70
1 files changed, 14 insertions, 56 deletions
diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp
index e046a62e..9dd1445e 100644
--- a/lib/csapi/peeking_events.cpp
+++ b/lib/csapi/peeking_events.cpp
@@ -4,71 +4,29 @@
#include "peeking_events.h"
-#include "converters.h"
+using namespace Quotient;
-#include <QtCore/QStringBuilder>
-
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class PeekEventsJob::Private
+auto queryToPeekEvents(const QString& from, Omittable<int> timeout,
+ const QString& roomId)
{
- public:
- QString begin;
- QString end;
- RoomEvents chunk;
-};
-
-BaseJob::Query queryToPeekEvents(const QString& from, Omittable<int> timeout, const QString& roomId)
-{
- BaseJob::Query _q;
+ QUrlQuery _q;
addParam<IfNotEmpty>(_q, QStringLiteral("from"), from);
addParam<IfNotEmpty>(_q, QStringLiteral("timeout"), timeout);
addParam<IfNotEmpty>(_q, QStringLiteral("room_id"), roomId);
return _q;
}
-QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from, Omittable<int> timeout, const QString& roomId)
+QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from,
+ Omittable<int> timeout, const QString& roomId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/events",
- queryToPeekEvents(from, timeout, roomId));
-}
-
-static const auto PeekEventsJobName = QStringLiteral("PeekEventsJob");
-
-PeekEventsJob::PeekEventsJob(const QString& from, Omittable<int> timeout, const QString& roomId)
- : BaseJob(HttpVerb::Get, PeekEventsJobName,
- basePath % "/events",
- queryToPeekEvents(from, timeout, roomId))
- , d(new Private)
-{
-}
-
-PeekEventsJob::~PeekEventsJob() = default;
-
-const QString& PeekEventsJob::begin() const
-{
- return d->begin;
-}
-
-const QString& PeekEventsJob::end() const
-{
- return d->end;
-}
-
-RoomEvents&& PeekEventsJob::chunk()
-{
- return std::move(d->chunk);
-}
-
-BaseJob::Status PeekEventsJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- d->begin = fromJson<QString>(json.value("start"_ls));
- d->end = fromJson<QString>(json.value("end"_ls));
- d->chunk = fromJson<RoomEvents>(json.value("chunk"_ls));
- return Success;
+ makePath("/_matrix/client/v3", "/events"),
+ queryToPeekEvents(from, timeout, roomId));
}
+PeekEventsJob::PeekEventsJob(const QString& from, Omittable<int> timeout,
+ const QString& roomId)
+ : BaseJob(HttpVerb::Get, QStringLiteral("PeekEventsJob"),
+ makePath("/_matrix/client/v3", "/events"),
+ queryToPeekEvents(from, timeout, roomId))
+{}