aboutsummaryrefslogtreecommitdiff
path: root/lib/csapi/admin.cpp
diff options
context:
space:
mode:
authorBlack Hat <bhat@encom.eu.org>2019-09-26 22:22:36 -0700
committerBlack Hat <bhat@encom.eu.org>2019-09-26 22:22:36 -0700
commit363cf452bcdbaf6ff1cf94a83ca66cbb31122346 (patch)
treec64c8fda885e4e1785130e8ee3e7c47fd18cbf67 /lib/csapi/admin.cpp
parent412e2cf19449e73aa7da729e9c5de6502687aade (diff)
parent944653463fe4134c82d85e2d01e2bc0fa43fd727 (diff)
downloadlibquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.tar.gz
libquotient-363cf452bcdbaf6ff1cf94a83ca66cbb31122346.zip
Merge branch 'master' of https://github.com/quotient-im/libQuotient into
bhat-libqtolm-update
Diffstat (limited to 'lib/csapi/admin.cpp')
-rw-r--r--lib/csapi/admin.cpp75
1 files changed, 38 insertions, 37 deletions
diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp
index ce06a56d..d2c20ba8 100644
--- a/lib/csapi/admin.cpp
+++ b/lib/csapi/admin.cpp
@@ -8,69 +8,70 @@
#include <QtCore/QStringBuilder>
-using namespace QMatrixClient;
+using namespace Quotient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
-namespace QMatrixClient
+// Converters
+namespace Quotient
{
- // Converters
- template <> struct JsonObjectConverter<GetWhoIsJob::ConnectionInfo>
+template <>
+struct JsonObjectConverter<GetWhoIsJob::ConnectionInfo>
+{
+ static void fillFrom(const QJsonObject& jo,
+ GetWhoIsJob::ConnectionInfo& result)
{
- 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>
+ 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)
{
- static void fillFrom(const QJsonObject& jo, GetWhoIsJob::SessionInfo& result)
- {
- fromJson(jo.value("connections"_ls), result.connections);
- }
- };
+ fromJson(jo.value("connections"_ls), result.connections);
+ }
+};
- template <> struct JsonObjectConverter<GetWhoIsJob::DeviceInfo>
+template <>
+struct JsonObjectConverter<GetWhoIsJob::DeviceInfo>
+{
+ static void fillFrom(const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result)
{
- static void fillFrom(const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result)
- {
- fromJson(jo.value("sessions"_ls), result.sessions);
- }
- };
-} // namespace QMatrixClient
+ fromJson(jo.value("sessions"_ls), result.sessions);
+ }
+};
+
+} // namespace Quotient
class GetWhoIsJob::Private
{
- public:
- QString userId;
- QHash<QString, DeviceInfo> devices;
+public:
+ QString userId;
+ QHash<QString, DeviceInfo> devices;
};
QUrl GetWhoIsJob::makeRequestUrl(QUrl baseUrl, const QString& userId)
{
return BaseJob::makeRequestUrl(std::move(baseUrl),
- basePath % "/admin/whois/" % userId);
+ basePath % "/admin/whois/" % userId);
}
static const auto GetWhoIsJobName = QStringLiteral("GetWhoIsJob");
GetWhoIsJob::GetWhoIsJob(const QString& userId)
: BaseJob(HttpVerb::Get, GetWhoIsJobName,
- basePath % "/admin/whois/" % userId)
+ basePath % "/admin/whois/" % userId)
, d(new Private)
-{
-}
+{}
GetWhoIsJob::~GetWhoIsJob() = default;
-const QString& GetWhoIsJob::userId() const
-{
- return d->userId;
-}
+const QString& GetWhoIsJob::userId() const { return d->userId; }
const QHash<QString, GetWhoIsJob::DeviceInfo>& GetWhoIsJob::devices() const
{
@@ -82,6 +83,6 @@ 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;
}
-