aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/event_context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/csapi/event_context.cpp')
-rw-r--r--lib/csapi/event_context.cpp67
1 files changed, 12 insertions, 55 deletions
diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp
index 5bb2222e..d2a5f522 100644
--- a/lib/csapi/event_context.cpp
+++ b/lib/csapi/event_context.cpp
@@ -4,79 +4,36 @@
#include "event_context.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
using namespace Quotient;
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class GetEventContextJob::Private {
-public:
- QString begin;
- QString end;
- RoomEvents eventsBefore;
- RoomEventPtr event;
- RoomEvents eventsAfter;
- StateEvents state;
-};
-
-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)
+ Omittable<int> limit,
+ const QString& filter)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/rooms/" % roomId % "/context/"
+ QStringLiteral("/_matrix/client/r0")
+ % "/rooms/" % roomId % "/context/"
% eventId,
- queryToGetEventContext(limit));
+ queryToGetEventContext(limit, filter));
}
GetEventContextJob::GetEventContextJob(const QString& roomId,
const QString& eventId,
- Omittable<int> limit)
+ Omittable<int> limit,
+ const QString& filter)
: BaseJob(HttpVerb::Get, QStringLiteral("GetEventContextJob"),
- basePath % "/rooms/" % roomId % "/context/" % eventId,
- queryToGetEventContext(limit))
- , d(new Private)
+ QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId
+ % "/context/" % eventId,
+ queryToGetEventContext(limit, filter))
{}
-
-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;
-}