aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/event_context.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2018-05-05 19:36:15 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2018-05-05 19:36:15 +0900
commita8d2a73c771f188fc0fdc6351b4923af788317d5 (patch)
treeb2795b93149f7c0ae3cd5005331b650a8eb6fd1e /lib/csapi/event_context.cpp
parentda16225dfbec9b155c2c299757203f7676ac6ccf (diff)
parenta63838235134b066c092ad98e1f18ff7991c91c1 (diff)
downloadlibquotient-a8d2a73c771f188fc0fdc6351b4923af788317d5.tar.gz
libquotient-a8d2a73c771f188fc0fdc6351b4923af788317d5.zip
Merge branch 'kitsune-gtad'
Diffstat (limited to 'lib/csapi/event_context.cpp')
-rw-r--r--lib/csapi/event_context.cpp91
1 files changed, 91 insertions, 0 deletions
diff --git a/lib/csapi/event_context.cpp b/lib/csapi/event_context.cpp
new file mode 100644
index 00000000..d9ab45ca
--- /dev/null
+++ b/lib/csapi/event_context.cpp
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
+ */
+
+#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;
+};
+
+BaseJob::Query queryToGetEventContext(int limit)
+{
+ BaseJob::Query _q;
+ _q.addQueryItem("limit", QString("%1").arg(limit));
+ return _q;
+}
+
+QUrl GetEventContextJob::makeRequestUrl(QUrl baseUrl, const QString& roomId, const QString& eventId, int limit)
+{
+ return BaseJob::makeRequestUrl(std::move(baseUrl),
+ basePath % "/rooms/" % roomId % "/context/" % eventId,
+ queryToGetEventContext(limit));
+}
+
+GetEventContextJob::GetEventContextJob(const QString& roomId, const QString& eventId, int limit)
+ : BaseJob(HttpVerb::Get, "GetEventContextJob",
+ 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();
+ d->begin = fromJson<QString>(json.value("start"));
+ d->end = fromJson<QString>(json.value("end"));
+ d->eventsBefore = fromJson<RoomEvents>(json.value("events_before"));
+ d->event = fromJson<RoomEventPtr>(json.value("event"));
+ d->eventsAfter = fromJson<RoomEvents>(json.value("events_after"));
+ d->state = fromJson<StateEvents>(json.value("state"));
+ return Success;
+}
+