blob: a0f7f67f5d71ae78f93bdfbd0a60191990edea58 (
plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
/******************************************************************************
* THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
*/
#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 FromJson<GetWhoIsJob::ConnectionInfo>
{
GetWhoIsJob::ConnectionInfo operator()(const QJsonValue& jv)
{
const auto& _json = jv.toObject();
GetWhoIsJob::ConnectionInfo result;
result.ip =
fromJson<QString>(_json.value("ip"));
result.lastSeen =
fromJson<qint64>(_json.value("last_seen"));
result.userAgent =
fromJson<QString>(_json.value("user_agent"));
return result;
}
};
template <> struct FromJson<GetWhoIsJob::SessionInfo>
{
GetWhoIsJob::SessionInfo operator()(const QJsonValue& jv)
{
const auto& _json = jv.toObject();
GetWhoIsJob::SessionInfo result;
result.connections =
fromJson<QVector<GetWhoIsJob::ConnectionInfo>>(_json.value("connections"));
return result;
}
};
template <> struct FromJson<GetWhoIsJob::DeviceInfo>
{
GetWhoIsJob::DeviceInfo operator()(const QJsonValue& jv)
{
const auto& _json = jv.toObject();
GetWhoIsJob::DeviceInfo result;
result.sessions =
fromJson<QVector<GetWhoIsJob::SessionInfo>>(_json.value("sessions"));
return result;
}
};
} // namespace QMatrixClient
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);
}
GetWhoIsJob::GetWhoIsJob(const QString& userId)
: BaseJob(HttpVerb::Get, "GetWhoIsJob",
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();
d->userId = fromJson<QString>(json.value("user_id"));
d->devices = fromJson<QHash<QString, DeviceInfo>>(json.value("devices"));
return Success;
}
|