1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/******************************************************************************
* THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
*/
#include "admin.h"
#include "converters.h"
#include <QtCore/QStringBuilder>
using namespace Quotient;
static const auto basePath = QStringLiteral("/_matrix/client/r0");
// Converters
namespace Quotient
{
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 Quotient
class GetWhoIsJob::Private
{
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);
}
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;
}
|