aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/whoami.cpp
diff options
context:
space:
mode:
authorn-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
committern-peugnet <n.peugnet@free.fr>2022-10-06 19:27:24 +0200
commitd911b207f49e936b3e992200796110f0749ed150 (patch)
tree96d20ebb4d074a4c1755e21cb316a52d584daee3 /lib/csapi/whoami.cpp
parent8ad8a74152c5701b6ca1f9a00487ba9257a439b4 (diff)
parent56c2f2e2b809b9077393eb617828f33d144f5634 (diff)
downloadlibquotient-d911b207f49e936b3e992200796110f0749ed150.tar.gz
libquotient-d911b207f49e936b3e992200796110f0749ed150.zip
New upstream version 0.7.0
Diffstat (limited to 'lib/csapi/whoami.cpp')
-rw-r--r--lib/csapi/whoami.cpp44
1 files changed, 6 insertions, 38 deletions
diff --git a/lib/csapi/whoami.cpp b/lib/csapi/whoami.cpp
index cb6439ef..af0c5d31 100644
--- a/lib/csapi/whoami.cpp
+++ b/lib/csapi/whoami.cpp
@@ -4,49 +4,17 @@
#include "whoami.h"
-#include "converters.h"
-
-#include <QtCore/QStringBuilder>
-
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-class GetTokenOwnerJob::Private
-{
- public:
- QString userId;
-};
+using namespace Quotient;
QUrl GetTokenOwnerJob::makeRequestUrl(QUrl baseUrl)
{
- return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/account/whoami");
+ return BaseJob::makeRequestUrl(
+ std::move(baseUrl), makePath("/_matrix/client/v3", "/account/whoami"));
}
-static const auto GetTokenOwnerJobName = QStringLiteral("GetTokenOwnerJob");
-
GetTokenOwnerJob::GetTokenOwnerJob()
- : BaseJob(HttpVerb::Get, GetTokenOwnerJobName,
- basePath % "/account/whoami")
- , d(new Private)
-{
-}
-
-GetTokenOwnerJob::~GetTokenOwnerJob() = default;
-
-const QString& GetTokenOwnerJob::userId() const
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetTokenOwnerJob"),
+ makePath("/_matrix/client/v3", "/account/whoami"))
{
- return d->userId;
+ addExpectedKey("user_id");
}
-
-BaseJob::Status GetTokenOwnerJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- if (!json.contains("user_id"_ls))
- return { JsonParseError,
- "The key 'user_id' not found in the response" };
- d->userId = fromJson<QString>(json.value("user_id"_ls));
- return Success;
-}
-