5 #include <Quotient/csapi/definitions/cross_signing_key.h>
6 #include <Quotient/csapi/definitions/device_keys.h>
8 #include <Quotient/e2ee/e2ee_common.h>
10 #include <Quotient/jobs/basejob.h>
45 explicit UploadKeysJob(
const std::optional<DeviceKeys>& deviceKeys = std::nullopt,
46 const OneTimeKeys& oneTimeKeys = {},
47 const OneTimeKeys& fallbackKeys = {});
55 QHash<QString,
int> oneTimeKeyCounts()
const
57 return loadFromJson<QHash<QString,
int>>(
"one_time_key_counts"_L1);
61 inline auto collectResponse(
const UploadKeysJob* job) {
return job->oneTimeKeyCounts(); }
75 QString deviceDisplayName{};
82 std::optional<UnsignedDeviceInfo> unsignedData{};
95 explicit QueryKeysJob(
const QHash<UserId, QStringList>& deviceKeys,
96 std::optional<
int> timeout = std::nullopt);
107 QHash<QString, QJsonObject> failures()
const
109 return loadFromJson<QHash<QString, QJsonObject>>(
"failures"_L1);
117 QHash<UserId, QHash<QString, DeviceInformation>> deviceKeys()
const
119 return loadFromJson<QHash<UserId, QHash<QString, DeviceInformation>>>(
"device_keys"_L1);
128 QHash<UserId, CrossSigningKey> masterKeys()
const
130 return loadFromJson<QHash<UserId, CrossSigningKey>>(
"master_keys"_L1);
137 QHash<UserId, CrossSigningKey> selfSigningKeys()
const
139 return loadFromJson<QHash<UserId, CrossSigningKey>>(
"self_signing_keys"_L1);
147 QHash<UserId, CrossSigningKey> userSigningKeys()
const
149 return loadFromJson<QHash<UserId, CrossSigningKey>>(
"user_signing_keys"_L1);
160 QHash<QString, QJsonObject> failures{};
167 QHash<UserId, QHash<QString, DeviceInformation>> deviceKeys{};
175 QHash<UserId, CrossSigningKey> masterKeys{};
181 QHash<UserId, CrossSigningKey> selfSigningKeys{};
188 QHash<UserId, CrossSigningKey> userSigningKeys{};
192 template <std::derived_from<QueryKeysJob> JobT>
193 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> QueryKeysJob::Response {
194 return { j->failures(), j->deviceKeys(), j->masterKeys(), j->selfSigningKeys(),
195 j->userSigningKeys() };
199 struct QUOTIENT_API JsonObjectConverter<QueryKeysJob::UnsignedDeviceInfo> {
200 static void fillFrom(
const QJsonObject& jo, QueryKeysJob::UnsignedDeviceInfo& result)
202 fillFromJson(jo.value(
"device_display_name"_L1), result.deviceDisplayName);
207 struct QUOTIENT_API JsonObjectConverter<QueryKeysJob::DeviceInformation> {
208 static void fillFrom(
const QJsonObject& jo, QueryKeysJob::DeviceInformation& result)
210 fillFromJson<DeviceKeys>(jo, result);
211 fillFromJson(jo.value(
"unsigned"_L1), result.unsignedData);
227 explicit ClaimKeysJob(
const QHash<UserId, QHash<QString, QString>>& oneTimeKeys,
228 std::optional<
int> timeout = std::nullopt);
239 QHash<QString, QJsonObject> failures()
const
241 return loadFromJson<QHash<QString, QJsonObject>>(
"failures"_L1);
252 QHash<UserId, QHash<QString, OneTimeKeys>> oneTimeKeys()
const
254 return loadFromJson<QHash<UserId, QHash<QString, OneTimeKeys>>>(
"one_time_keys"_L1);
265 QHash<QString, QJsonObject> failures{};
275 QHash<UserId, QHash<QString, OneTimeKeys>> oneTimeKeys{};
279 template <std::derived_from<ClaimKeysJob> JobT>
280 constexpr inline auto doCollectResponse<JobT> =
281 [](JobT* j) -> ClaimKeysJob::Response {
return { j->failures(), j->oneTimeKeys() }; };
308 explicit GetKeysChangesJob(
const QString& from,
const QString& to);
314 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& from,
const QString& to);
320 QStringList changed()
const {
return loadFromJson<QStringList>(
"changed"_L1); }
325 QStringList left()
const {
return loadFromJson<QStringList>(
"left"_L1); }
330 QStringList changed{};
339 template <std::derived_from<GetKeysChangesJob> JobT>
340 constexpr inline auto doCollectResponse<JobT> =
341 [](JobT* j) -> GetKeysChangesJob::Response {
return { j->changed(), j->left() }; };