diff options
Diffstat (limited to 'lib/csapi/admin.cpp')
-rw-r--r-- | lib/csapi/admin.cpp | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/lib/csapi/admin.cpp b/lib/csapi/admin.cpp index ce06a56d..7922ffe3 100644 --- a/lib/csapi/admin.cpp +++ b/lib/csapi/admin.cpp @@ -12,13 +12,12 @@ using namespace QMatrixClient; static const auto basePath = QStringLiteral("/_matrix/client/r0"); -namespace QMatrixClient -{ +namespace QMatrixClient { // Converters - template <> struct JsonObjectConverter<GetWhoIsJob::ConnectionInfo> - { - static void fillFrom(const QJsonObject& jo, GetWhoIsJob::ConnectionInfo& result) + 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); @@ -26,17 +25,17 @@ namespace QMatrixClient } }; - template <> struct JsonObjectConverter<GetWhoIsJob::SessionInfo> - { - static void fillFrom(const QJsonObject& jo, GetWhoIsJob::SessionInfo& result) + 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) + template <> struct JsonObjectConverter<GetWhoIsJob::DeviceInfo> { + static void fillFrom(const QJsonObject& jo, + GetWhoIsJob::DeviceInfo& result) { fromJson(jo.value("sessions"_ls), result.sessions); } @@ -46,31 +45,28 @@ namespace QMatrixClient class GetWhoIsJob::Private { public: - QString userId; - QHash<QString, DeviceInfo> devices; + 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) - , d(new Private) + 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 { @@ -84,4 +80,3 @@ BaseJob::Status GetWhoIsJob::parseJson(const QJsonDocument& data) fromJson(json.value("devices"_ls), d->devices); return Success; } - |