diff options
Diffstat (limited to 'lib/csapi/peeking_events.cpp')
-rw-r--r-- | lib/csapi/peeking_events.cpp | 41 |
1 files changed, 7 insertions, 34 deletions
diff --git a/lib/csapi/peeking_events.cpp b/lib/csapi/peeking_events.cpp index 4d886812..70a5b6f3 100644 --- a/lib/csapi/peeking_events.cpp +++ b/lib/csapi/peeking_events.cpp @@ -4,23 +4,12 @@ #include "peeking_events.h" -#include "converters.h" - #include <QtCore/QStringBuilder> using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class PeekEventsJob::Private { -public: - QString begin; - QString end; - RoomEvents chunk; -}; - -BaseJob::Query queryToPeekEvents(const QString& from, Omittable<int> timeout, - const QString& roomId) +auto queryToPeekEvents(const QString& from, Omittable<int> timeout, + const QString& roomId) { BaseJob::Query _q; addParam<IfNotEmpty>(_q, QStringLiteral("from"), from); @@ -32,31 +21,15 @@ BaseJob::Query queryToPeekEvents(const QString& from, Omittable<int> timeout, QUrl PeekEventsJob::makeRequestUrl(QUrl baseUrl, const QString& from, Omittable<int> timeout, const QString& roomId) { - return BaseJob::makeRequestUrl(std::move(baseUrl), basePath % "/events", + return BaseJob::makeRequestUrl(std::move(baseUrl), + QStringLiteral("/_matrix/client/r0") + % "/events", queryToPeekEvents(from, timeout, roomId)); } PeekEventsJob::PeekEventsJob(const QString& from, Omittable<int> timeout, const QString& roomId) : BaseJob(HttpVerb::Get, QStringLiteral("PeekEventsJob"), - basePath % "/events", queryToPeekEvents(from, timeout, roomId)) - , d(new Private) + QStringLiteral("/_matrix/client/r0") % "/events", + queryToPeekEvents(from, timeout, roomId)) {} - -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(); - fromJson(json.value("start"_ls), d->begin); - fromJson(json.value("end"_ls), d->end); - fromJson(json.value("chunk"_ls), d->chunk); - - return Success; -} |