5 #include <Quotient/jobs/basejob.h>
25 std::optional<qint64> lastSeen{};
33 QVector<ConnectionInfo> connections{};
38 QVector<SessionInfo> sessions{};
45 explicit GetWhoIsJob(
const QString& userId);
51 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& userId);
56 QString userId()
const {
return loadFromJson<QString>(
"user_id"_L1); }
59 QHash<QString, DeviceInfo> devices()
const
61 return loadFromJson<QHash<QString, DeviceInfo>>(
"devices"_L1);
69 QHash<QString, DeviceInfo> devices{};
73 template <std::derived_from<GetWhoIsJob> JobT>
74 constexpr inline auto doCollectResponse<JobT> =
75 [](JobT* j) -> GetWhoIsJob::Response {
return { j->userId(), j->devices() }; };
78 struct QUOTIENT_API JsonObjectConverter<GetWhoIsJob::ConnectionInfo> {
79 static void fillFrom(
const QJsonObject& jo, GetWhoIsJob::ConnectionInfo& result)
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);
88 struct QUOTIENT_API JsonObjectConverter<GetWhoIsJob::SessionInfo> {
89 static void fillFrom(
const QJsonObject& jo, GetWhoIsJob::SessionInfo& result)
91 fillFromJson(jo.value(
"connections"_L1), result.connections);
96 struct QUOTIENT_API JsonObjectConverter<GetWhoIsJob::DeviceInfo> {
97 static void fillFrom(
const QJsonObject& jo, GetWhoIsJob::DeviceInfo& result)
99 fillFromJson(jo.value(
"sessions"_L1), result.sessions);