libQuotient
A Qt library for building matrix clients
Loading...
Searching...
No Matches
admin.h
Go to the documentation of this file.
1
// THIS FILE IS GENERATED - ANY EDITS WILL BE OVERWRITTEN
2
3
#
pragma
once
4
5
#
include
<
Quotient
/
jobs
/
basejob
.
h
>
6
7
namespace
Quotient
{
8
9
//! \brief Gets information about a particular user.
10
//!
11
//! Gets information about a particular user.
12
//!
13
//! This API may be restricted to only be called by the user being looked
14
//! up, or by a server admin. Server-local administrator privileges are not
15
//! specified in this document.
16
class
QUOTIENT_API
GetWhoIsJob
:
public
BaseJob
{
17
public
:
18
// Inner data structures
19
20
struct
QUOTIENT_API
ConnectionInfo
{
21
//! Most recently seen IP address of the session.
22
QString
ip
{};
23
24
//! Unix timestamp that the session was last active.
25
std
::
optional
<
qint64
>
lastSeen
{};
26
27
//! User agent string last seen in the session.
28
QString
userAgent
{};
29
};
30
31
struct
QUOTIENT_API
SessionInfo
{
32
//! Information particular connections in the session.
33
QVector
<
ConnectionInfo
>
connections
{};
34
};
35
36
struct
QUOTIENT_API
DeviceInfo
{
37
//! A user's sessions (i.e. what they did with an access token from one login).
38
QVector
<
SessionInfo
>
sessions
{};
39
};
40
41
// Construction/destruction
42
43
//! \param userId
44
//! The user to look up.
45
explicit
GetWhoIsJob
(
const
QString
&
userId
);
46
47
//! \brief Construct a URL without creating a full-fledged job object
48
//!
49
//! This function can be used when a URL for GetWhoIsJob
50
//! is necessary but the job itself isn't.
51
static
QUrl
makeRequestUrl
(
const
HomeserverData
&
hsData
,
const
QString
&
userId
);
52
53
// Result properties
54
55
//! The Matrix user ID of the user.
56
QString
userId
()
const
{
return
loadFromJson
<
QString
>(
"user_id"_L1
); }
57
58
//! Each key is an identifier for one of the user's devices.
59
QHash
<
QString
,
DeviceInfo
>
devices
()
const
60
{
61
return
loadFromJson
<
QHash
<
QString
,
DeviceInfo
>>(
"devices"_L1
);
62
}
63
64
struct
Response
{
65
//! The Matrix user ID of the user.
66
QString
userId
{};
67
68
//! Each key is an identifier for one of the user's devices.
69
QHash
<
QString
,
DeviceInfo
>
devices
{};
70
};
71
};
72
73
template
<
std
::
derived_from
<
GetWhoIsJob
>
JobT
>
74
constexpr
inline
auto
doCollectResponse
<
JobT
> =
75
[](
JobT
*
j
) ->
GetWhoIsJob
::
Response
{
return
{
j
->
userId
(),
j
->
devices
() }; };
76
77
template
<>
78
struct
QUOTIENT_API
JsonObjectConverter
<
GetWhoIsJob
::
ConnectionInfo
> {
79
static
void
fillFrom
(
const
QJsonObject
&
jo
,
GetWhoIsJob
::
ConnectionInfo
&
result
)
80
{
81
fillFromJson
(
jo
.
value
(
"ip"_L1
),
result
.
ip
);
82
fillFromJson
(
jo
.
value
(
"last_seen"_L1
),
result
.
lastSeen
);
83
fillFromJson
(
jo
.
value
(
"user_agent"_L1
),
result
.
userAgent
);
84
}
85
};
86
87
template
<>
88
struct
QUOTIENT_API
JsonObjectConverter
<
GetWhoIsJob
::
SessionInfo
> {
89
static
void
fillFrom
(
const
QJsonObject
&
jo
,
GetWhoIsJob
::
SessionInfo
&
result
)
90
{
91
fillFromJson
(
jo
.
value
(
"connections"_L1
),
result
.
connections
);
92
}
93
};
94
95
template
<>
96
struct
QUOTIENT_API
JsonObjectConverter
<
GetWhoIsJob
::
DeviceInfo
> {
97
static
void
fillFrom
(
const
QJsonObject
&
jo
,
GetWhoIsJob
::
DeviceInfo
&
result
)
98
{
99
fillFromJson
(
jo
.
value
(
"sessions"_L1
),
result
.
sessions
);
100
}
101
};
102
103
}
// namespace Quotient
Quotient::GetWhoIsJob
Gets information about a particular user.
Definition
admin.h:16
Quotient
Definition
accountregistry.h:13
QUOTIENT_API
#define QUOTIENT_API
Definition
quotient_export.h:22
Quotient
csapi
admin.h
Generated by
1.9.8