5 #include <Quotient/csapi/definitions/key_backup_data.h>
6 #include <Quotient/csapi/definitions/room_key_backup.h>
8 #include <Quotient/jobs/basejob.h>
24 explicit PostRoomKeysVersionJob(
const QString& algorithm,
const QJsonObject& authData);
29 QString version()
const {
return loadFromJson<QString>(
"version"_L1); }
32 inline auto collectResponse(
const PostRoomKeysVersionJob* job) {
return job->version(); }
39 explicit GetRoomKeysVersionCurrentJob();
45 static QUrl makeRequestUrl(
const HomeserverData& hsData);
50 QString algorithm()
const {
return loadFromJson<QString>(
"algorithm"_L1); }
55 QJsonObject authData()
const {
return loadFromJson<QJsonObject>(
"auth_data"_L1); }
58 int count()
const {
return loadFromJson<
int>(
"count"_L1); }
64 QString etag()
const {
return loadFromJson<QString>(
"etag"_L1); }
67 QString version()
const {
return loadFromJson<QString>(
"version"_L1); }
76 QJsonObject authData{};
92 template <std::derived_from<GetRoomKeysVersionCurrentJob> JobT>
93 constexpr inline auto doCollectResponse<JobT> =
94 [](JobT* j) -> GetRoomKeysVersionCurrentJob::Response {
95 return { j->algorithm(), j->authData(), j->count(), j->etag(), j->version() };
109 explicit GetRoomKeysVersionJob(
const QString& version);
115 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& version);
120 QString algorithm()
const {
return loadFromJson<QString>(
"algorithm"_L1); }
125 QJsonObject authData()
const {
return loadFromJson<QJsonObject>(
"auth_data"_L1); }
128 int count()
const {
return loadFromJson<
int>(
"count"_L1); }
134 QString etag()
const {
return loadFromJson<QString>(
"etag"_L1); }
137 QString version()
const {
return loadFromJson<QString>(
"version"_L1); }
146 QJsonObject authData{};
162 template <std::derived_from<GetRoomKeysVersionJob> JobT>
163 constexpr inline auto doCollectResponse<JobT> = [](JobT* j) -> GetRoomKeysVersionJob::Response {
164 return { j->algorithm(), j->authData(), j->count(), j->etag(), j->version() };
188 explicit PutRoomKeysVersionJob(
const QString& version,
const QString& algorithm,
189 const QJsonObject& authData);
205 explicit DeleteRoomKeysVersionJob(
const QString& version);
211 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& version);
230 explicit PutRoomKeyBySessionIdJob(
const QString& roomId,
const QString& sessionId,
231 const QString& version,
const KeyBackupData& data);
237 QString etag()
const {
return loadFromJson<QString>(
"etag"_L1); }
240 int count()
const {
return loadFromJson<
int>(
"count"_L1); }
252 template <std::derived_from<PutRoomKeyBySessionIdJob> JobT>
253 constexpr inline auto doCollectResponse<JobT> =
254 [](JobT* j) -> PutRoomKeyBySessionIdJob::Response {
return { j->etag(), j->count() }; };
269 explicit GetRoomKeyBySessionIdJob(
const QString& roomId,
const QString& sessionId,
270 const QString& version);
276 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& roomId,
277 const QString& sessionId,
const QString& version);
282 KeyBackupData data()
const {
return fromJson<KeyBackupData>(jsonData()); }
285 inline auto collectResponse(
const GetRoomKeyBySessionIdJob* job) {
return job->data(); }
300 explicit DeleteRoomKeyBySessionIdJob(
const QString& roomId,
const QString& sessionId,
301 const QString& version);
307 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& roomId,
308 const QString& sessionId,
const QString& version);
314 QString etag()
const {
return loadFromJson<QString>(
"etag"_L1); }
317 int count()
const {
return loadFromJson<
int>(
"count"_L1); }
329 template <std::derived_from<DeleteRoomKeyBySessionIdJob> JobT>
330 constexpr inline auto doCollectResponse<JobT> =
331 [](JobT* j) -> DeleteRoomKeyBySessionIdJob::Response {
return { j->etag(), j->count() }; };
346 explicit PutRoomKeysByRoomIdJob(
const QString& roomId,
const QString& version,
347 const RoomKeyBackup& backupData);
353 QString etag()
const {
return loadFromJson<QString>(
"etag"_L1); }
356 int count()
const {
return loadFromJson<
int>(
"count"_L1); }
368 template <std::derived_from<PutRoomKeysByRoomIdJob> JobT>
369 constexpr inline auto doCollectResponse<JobT> =
370 [](JobT* j) -> PutRoomKeysByRoomIdJob::Response {
return { j->etag(), j->count() }; };
382 explicit GetRoomKeysByRoomIdJob(
const QString& roomId,
const QString& version);
388 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& roomId,
389 const QString& version);
395 RoomKeyBackup data()
const {
return fromJson<RoomKeyBackup>(jsonData()); }
398 inline auto collectResponse(
const GetRoomKeysByRoomIdJob* job) {
return job->data(); }
410 explicit DeleteRoomKeysByRoomIdJob(
const QString& roomId,
const QString& version);
416 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& roomId,
417 const QString& version);
423 QString etag()
const {
return loadFromJson<QString>(
"etag"_L1); }
426 int count()
const {
return loadFromJson<
int>(
"count"_L1); }
438 template <std::derived_from<DeleteRoomKeysByRoomIdJob> JobT>
439 constexpr inline auto doCollectResponse<JobT> =
440 [](JobT* j) -> DeleteRoomKeysByRoomIdJob::Response {
return { j->etag(), j->count() }; };
452 explicit PutRoomKeysJob(
const QString& version,
const QHash<RoomId, RoomKeyBackup>& rooms);
458 QString etag()
const {
return loadFromJson<QString>(
"etag"_L1); }
461 int count()
const {
return loadFromJson<
int>(
"count"_L1); }
473 template <std::derived_from<PutRoomKeysJob> JobT>
474 constexpr inline auto doCollectResponse<JobT> =
475 [](JobT* j) -> PutRoomKeysJob::Response {
return { j->etag(), j->count() }; };
484 explicit GetRoomKeysJob(
const QString& version);
490 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& version);
495 QHash<RoomId, RoomKeyBackup> rooms()
const
497 return loadFromJson<QHash<RoomId, RoomKeyBackup>>(
"rooms"_L1);
501 inline auto collectResponse(
const GetRoomKeysJob* job) {
return job->rooms(); }
510 explicit DeleteRoomKeysJob(
const QString& version);
516 static QUrl makeRequestUrl(
const HomeserverData& hsData,
const QString& version);
522 QString etag()
const {
return loadFromJson<QString>(
"etag"_L1); }
525 int count()
const {
return loadFromJson<
int>(
"count"_L1); }
537 template <std::derived_from<DeleteRoomKeysJob> JobT>
538 constexpr inline auto doCollectResponse<JobT> =
539 [](JobT* j) -> DeleteRoomKeysJob::Response {
return { j->etag(), j->count() }; };