aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/room_state.cpp
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2020-06-09 08:52:25 +0200
committerGitHub <noreply@github.com>2020-06-09 08:52:25 +0200
commit370d9b3e46332d38df8798cda208c534c58be808 (patch)
treef3db0cd7463468ff52c74446acd608356f8b8ab6 /lib/csapi/room_state.cpp
parente1f5d0aa2c33e6da6c3a609c8bc7e0b5867e748d (diff)
parent10d9ac4673e374a9ac17ff492591136520337c4c (diff)
downloadlibquotient-370d9b3e46332d38df8798cda208c534c58be808.tar.gz
libquotient-370d9b3e46332d38df8798cda208c534c58be808.zip
Merge pull request #405 from quotient-im/kitsune-basejob-store-json-response
Store JSON response in BaseJob + tweaks to the generated code
Diffstat (limited to 'lib/csapi/room_state.cpp')
-rw-r--r--lib/csapi/room_state.cpp53
1 files changed, 3 insertions, 50 deletions
diff --git a/lib/csapi/room_state.cpp b/lib/csapi/room_state.cpp
index 5973b06b..e18108ac 100644
--- a/lib/csapi/room_state.cpp
+++ b/lib/csapi/room_state.cpp
@@ -4,65 +4,18 @@
#include "room_state.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
using namespace Quotient;
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class SetRoomStateWithKeyJob::Private {
-public:
- QString eventId;
-};
-
SetRoomStateWithKeyJob::SetRoomStateWithKeyJob(const QString& roomId,
const QString& eventType,
const QString& stateKey,
const QJsonObject& body)
: BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateWithKeyJob"),
- basePath % "/rooms/" % roomId % "/state/" % eventType % "/"
- % stateKey)
- , d(new Private)
-{
- setRequestData(Data(toJson(body)));
-}
-
-SetRoomStateWithKeyJob::~SetRoomStateWithKeyJob() = default;
-
-const QString& SetRoomStateWithKeyJob::eventId() const { return d->eventId; }
-
-BaseJob::Status SetRoomStateWithKeyJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- fromJson(json.value("event_id"_ls), d->eventId);
-
- return Success;
-}
-
-class SetRoomStateJob::Private {
-public:
- QString eventId;
-};
-
-SetRoomStateJob::SetRoomStateJob(const QString& roomId, const QString& eventType,
- const QJsonObject& body)
- : BaseJob(HttpVerb::Put, QStringLiteral("SetRoomStateJob"),
- basePath % "/rooms/" % roomId % "/state/" % eventType)
- , d(new Private)
+ QStringLiteral("/_matrix/client/r0") % "/rooms/" % roomId
+ % "/state/" % eventType % "/" % stateKey)
{
setRequestData(Data(toJson(body)));
-}
-
-SetRoomStateJob::~SetRoomStateJob() = default;
-
-const QString& SetRoomStateJob::eventId() const { return d->eventId; }
-
-BaseJob::Status SetRoomStateJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- fromJson(json.value("event_id"_ls), d->eventId);
-
- return Success;
+ addExpectedKey("event_id");
}