diff options
author | Andres Salomon <dilinger@queued.net> | 2021-01-18 04:00:14 -0500 |
---|---|---|
committer | Andres Salomon <dilinger@queued.net> | 2021-01-18 04:00:14 -0500 |
commit | 09eb39236666e81d5da014acea011dcd74d0999b (patch) | |
tree | 52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/event_context.cpp | |
parent | f1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff) | |
parent | a4e78956f105875625b572d8b98459ffa86fafe5 (diff) | |
download | libquotient-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/event_context.cpp')
-rw-r--r-- | lib/csapi/event_context.cpp | 98 |
1 files changed, 22 insertions, 76 deletions
diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp index bb1f5301..d2a5f522 100644 --- a/lib/csapi/event_context.cpp +++ b/lib/csapi/event_context.cpp @@ -4,90 +4,36 @@ #include "event_context.h" -#include "converters.h" - #include <QtCore/QStringBuilder> -using namespace QMatrixClient; - -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - -class GetEventContextJob::Private -{ - public: - QString begin; - QString end; - RoomEvents eventsBefore; - RoomEventPtr event; - RoomEvents eventsAfter; - StateEvents state; -}; +using namespace Quotient; -BaseJob::Query queryToGetEventContext(Omittable<int> limit) +auto queryToGetEventContext(Omittable<int> limit, const QString& filter) { BaseJob::Query _q; addParam<IfNotEmpty>(_q, QStringLiteral("limit"), limit); + addParam<IfNotEmpty>(_q, QStringLiteral("filter"), filter); return _q; } -QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, Omittable<int> limit) +QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, + const QString& eventId, + Omittable<int> limit, + const QString& filter) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/rooms/" % roomId % "/context/" % eventId, - queryToGetEventContext(limit)); -} - -static const auto GetEventContextJobName = QStringLiteral("GetEventContextJob"); - -GetEventContextJob::GetEventContextJob(const QString& roomId, const QString& eventId, Omittable<int> limit) - : BaseJob(HttpVerb::Get, GetEventContextJobName, - basePath % "/rooms/" % roomId % "/context/" % eventId, - queryToGetEventContext(limit)) - , d(new Private) -{ -} - -GetEventContextJob::~GetEventContextJob() = default; - -const QString& GetEventContextJob::begin() const -{ - return d->begin; -} - -const QString& GetEventContextJob::end() const -{ - return d->end; -} - -RoomEvents&& GetEventContextJob::eventsBefore() -{ - return std::move(d->eventsBefore); -} - -RoomEventPtr&& GetEventContextJob::event() -{ - return std::move(d->event); -} - -RoomEvents&& GetEventContextJob::eventsAfter() -{ - return std::move(d->eventsAfter); -} - -StateEvents&& GetEventContextJob::state() -{ - return std::move(d->state); -} - -BaseJob::Status GetEventContextJob::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("events_before"_ls), d->eventsBefore); - fromJson(json.value("event"_ls), d->event); - fromJson(json.value("events_after"_ls), d->eventsAfter); - fromJson(json.value("state"_ls), d->state); - return Success; -} - + QStringLiteral("/_matrix/client/r0") + % "/rooms/" % roomId % "/context/" + % eventId, + queryToGetEventContext(limit, filter)); +} + +GetEventContextJob::GetEventContextJob(const QString& roomId, + const QString& eventId, + Omittable<int> limit, + const QString& filter) + : BaseJob(HttpVerb::Get, QStringLiteral("GetEventContextJob"), + QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId + % "/context/" % eventId, + queryToGetEventContext(limit, filter)) +{} |