From 32729d9a7519cd2c4cddb0174b8329c6fd4a4a83 Mon Sep 17 00:00:00 2001 From: Kitsune Ral Date: Sun, 7 Jun 2020 19:46:40 +0200 Subject: Update generated files according to gtad/* changes --- lib/csapi/presence.cpp | 54 ++++++++------------------------------------------ 1 file changed, 8 insertions(+), 46 deletions(-) (limited to 'lib/csapi/presence.cpp') diff --git a/lib/csapi/presence.cpp b/lib/csapi/presence.cpp index 932ccc6e..58d0d157 100644 --- a/lib/csapi/presence.cpp +++ b/lib/csapi/presence.cpp @@ -4,71 +4,33 @@ #include "presence.h" -#include "converters.h" - #include using namespace Quotient; -static const auto basePath = QStringLiteral("/_matrix/client/r0"); - SetPresenceJob::SetPresenceJob(const QString& userId, const QString& presence, const QString& statusMsg) : BaseJob(HttpVerb::Put, QStringLiteral("SetPresenceJob"), - basePath % "/presence/" % userId % "/status") + QStringLiteral("/_matrix/client/r0") % "/presence/" % userId + % "/status") { QJsonObject _data; addParam<>(_data, QStringLiteral("presence"), presence); addParam(_data, QStringLiteral("status_msg"), statusMsg); - setRequestData(_data); + setRequestData(std::move(_data)); } -class GetPresenceJob::Private { -public: - QString presence; - Omittable lastActiveAgo; - QString statusMsg; - Omittable currentlyActive; -}; - QUrl GetPresenceJob::makeRequestUrl(QUrl baseUrl, const QString& userId) { return BaseJob::makeRequestUrl(std::move(baseUrl), - basePath % "/presence/" % userId % "/status"); + QStringLiteral("/_matrix/client/r0") + % "/presence/" % userId % "/status"); } GetPresenceJob::GetPresenceJob(const QString& userId) : BaseJob(HttpVerb::Get, QStringLiteral("GetPresenceJob"), - basePath % "/presence/" % userId % "/status") - , d(new Private) -{} - -GetPresenceJob::~GetPresenceJob() = default; - -const QString& GetPresenceJob::presence() const { return d->presence; } - -Omittable GetPresenceJob::lastActiveAgo() const -{ - return d->lastActiveAgo; -} - -const QString& GetPresenceJob::statusMsg() const { return d->statusMsg; } - -Omittable GetPresenceJob::currentlyActive() const + QStringLiteral("/_matrix/client/r0") % "/presence/" % userId + % "/status") { - return d->currentlyActive; -} - -BaseJob::Status GetPresenceJob::parseJson(const QJsonDocument& data) -{ - auto json = data.object(); - if (!json.contains("presence"_ls)) - return { IncorrectResponse, - "The key 'presence' not found in the response" }; - fromJson(json.value("presence"_ls), d->presence); - fromJson(json.value("last_active_ago"_ls), d->lastActiveAgo); - fromJson(json.value("status_msg"_ls), d->statusMsg); - fromJson(json.value("currently_active"_ls), d->currentlyActive); - - return Success; + addExpectedKey("presence"); } -- cgit v1.2.3