aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/admin.cpp
diff options
context:
space:
mode:
authorAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
committerAndres Salomon <dilinger@queued.net>2021-01-18 04:00:14 -0500
commit09eb39236666e81d5da014acea011dcd74d0999b (patch)
tree52876d96be71be1a39d5d935c1295a51995e8949 /lib/csapi/admin.cpp
parentf1788ee27f33e9339334e0d79bde9a27d9ce2e44 (diff)
parenta4e78956f105875625b572d8b98459ffa86fafe5 (diff)
downloadlibquotient-09eb39236666e81d5da014acea011dcd74d0999b.tar.gz
libquotient-09eb39236666e81d5da014acea011dcd74d0999b.zip
Update upstream source from tag 'upstream/0.6.4'
Update to upstream version '0.6.4' with Debian dir aa8705fd74743e79c043bc9e3e425d5064404cfe
Diffstat (limited to 'lib/csapi/admin.cpp')
-rw-r--r--lib/csapi/admin.cpp78
1 files changed, 6 insertions, 72 deletions
diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp
index ce06a56d..9619c441 100644
--- a/lib/csapi/admin.cpp
+++ b/lib/csapi/admin.cpp
@@ -4,84 +4,18 @@
#include "admin.h"
-#include "converters.h"
-
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
-
-static const auto basePath = QStringLiteral("/_matrix/client/r0");
-
-namespace QMatrixClient
-{
- // Converters
-
- template <> struct JsonObjectConverter<GetWhoIsJob::ConnectionInfo>
- {
- static void fillFrom(const QJsonObject& jo, GetWhoIsJob::ConnectionInfo& result)
- {
- fromJson(jo.value("ip"_ls), result.ip);
- fromJson(jo.value("last_seen"_ls), result.lastSeen);
- fromJson(jo.value("user_agent"_ls), result.userAgent);
- }
- };
-
- template <> struct JsonObjectConverter<GetWhoIsJob::SessionInfo>
- {
- static void fillFrom(const QJsonObject& jo, GetWhoIsJob::SessionInfo& result)
- {
- fromJson(jo.value("connections"_ls), result.connections);
- }
- };
-
- template <> struct JsonObjectConverter<GetWhoIsJob::DeviceInfo>
- {
- static void fillFrom(const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result)
- {
- fromJson(jo.value("sessions"_ls), result.sessions);
- }
- };
-} // namespace QMatrixClient
-
-class GetWhoIsJob::Private
-{
- public:
- QString userId;
- QHash<QString, DeviceInfo> devices;
-};
+using namespace Quotient;
QUrl GetWhoIsJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/admin/whois/" % userId);
+ QStringLiteral("/_matrix/client/r0")
+ % "/admin/whois/" % userId);
}
-static const auto GetWhoIsJobName = QStringLiteral("GetWhoIsJob");
-
GetWhoIsJob::GetWhoIsJob(const QString& userId)
- : BaseJob(HttpVerb::Get, GetWhoIsJobName,
- basePath % "/admin/whois/" % userId)
- , d(new Private)
-{
-}
-
-GetWhoIsJob::~GetWhoIsJob() = default;
-
-const QString& GetWhoIsJob::userId() const
-{
- return d->userId;
-}
-
-const QHash<QString, GetWhoIsJob::DeviceInfo>& GetWhoIsJob::devices() const
-{
- return d->devices;
-}
-
-BaseJob::Status GetWhoIsJob::parseJson(const QJsonDocument& data)
-{
- auto json = data.object();
- fromJson(json.value("user_id"_ls), d->userId);
- fromJson(json.value("devices"_ls), d->devices);
- return Success;
-}
-
+ : BaseJob(HttpVerb::Get, QStringLiteral("GetWhoIsJob"),
+ QStringLiteral("/_matrix/client/r0") % "/admin/whois/" % userId)
+{}