libkazv
client-model.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of libkazv.
3  * SPDX-FileCopyrightText: 2020-2024 tusooa <tusooa@kazv.moe>
4  * SPDX-License-Identifier: AGPL-3.0-or-later
5  */
6 
7 
8 #pragma once
9 #include <libkazv-config.hpp>
10 
11 #include <tuple>
12 #include <variant>
13 #include <string>
14 #include <optional>
15 
16 #include <lager/context.hpp>
17 #include <boost/hana.hpp>
19 
20 
21 #include <csapi/sync.hpp>
22 
23 #include <file-desc.hpp>
24 #include <crypto.hpp>
25 
30 
31 #include "clientfwd.hpp"
32 #include "device-list-tracker.hpp"
33 #include "room/room-model.hpp"
34 
35 namespace Kazv
36 {
37  inline const std::string DEFTXNID{"0"};
38 
40  {
43  };
44 
46  {
50  };
51 
53  {
56  };
57 
58  struct ClientModel
59  {
60  std::string serverUrl;
61  std::string userId;
62  std::string token;
63  std::string deviceId;
64  bool loggedIn{false};
65 
66  bool syncing{false};
67  bool shouldSync{true};
68  int firstRetryMs{1000};
70  int maxRetryMs{30 * 1000};
71  int syncTimeoutMs{20000};
72  std::string initialSyncFilterId;
74  std::optional<std::string> syncToken;
75 
77  immer::map<std::string /* sender */, Event> presence;
78  immer::map<std::string /* type */, Event> accountData;
79 
80  std::string nextTxnId{DEFTXNID};
81  immer::flex_vector<BaseJob> nextJobs;
82  immer::flex_vector<KazvEvent> nextTriggers;
83 
85  std::optional<immer::box<Crypto>> crypto;
86  bool identityKeysUploaded{false};
87 
90 
91  immer::flex_vector<std::string /* deviceId */> devicesToSendKeys(std::string userId) const;
92 
95  void maybeRotateSessions(ClientModel oldClient);
96 
97  std::pair<Event, std::optional<std::string> /* sessionKey */>
98  megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random);
100  Event olmEncrypt(Event e, immer::map<std::string, immer::flex_vector<std::string>> userIdToDeviceIdMap, RandomData random);
101 
103  std::size_t numOneTimeKeysNeeded() const;
104 
106  auto directRoomMap() const -> immer::map<std::string, std::string>;
107 
108  auto roomIdsUnderTag(std::string tagId) const -> immer::map<std::string, double>;
109 
110  auto roomIdsByTagId() const -> immer::map<std::string, immer::map<std::string, double>>;
111 
115  const Crypto &constCrypto() const;
116 
120  template<class Func>
121  auto withCrypto(Func &&func) -> std::decay_t<std::invoke_result_t<Func &&, Crypto &>>
122  {
123  using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
124  if constexpr (std::is_same_v<ResT, void>) {
125  crypto = std::move(crypto).value()
126  .update([f=std::forward<Func>(func)](Crypto c) mutable {
127  std::forward<Func>(f)(c);
128  return c;
129  });
130  } else {
131  std::optional<ResT> res;
132  crypto = std::move(crypto).value()
133  .update([f=std::forward<Func>(func), &res](Crypto c) mutable {
134  res = std::forward<Func>(f)(c);
135  return c;
136  });
137  return std::move(res).value();
138  }
139  }
140 
141  // helpers
142  template<class Job>
143  struct MakeJobT
144  {
145  template<class ...Args>
146  constexpr auto make(Args &&...args) const {
147  if constexpr (Job::needsAuth()) {
148  return Job(
149  serverUrl,
150  token,
151  std::forward<Args>(args)...);
152  } else {
153  return Job(
154  serverUrl,
155  std::forward<Args>(args)...);
156  }
157  }
158 
159  std::string serverUrl;
160  std::string token;
161  };
162 
163  template<class Job>
164  constexpr auto job() const {
165  return MakeJobT<Job>{serverUrl, token};
166  }
167 
168  inline void addJob(BaseJob j) {
169  nextJobs = std::move(nextJobs).push_back(std::move(j));
170  }
171 
172  inline auto popAllJobs() {
173  auto jobs = std::move(nextJobs);
174  nextJobs = DEFVAL;
175  return jobs;
176  };
177 
178  inline void addTrigger(KazvEvent t) {
179  addTriggers({t});
180  }
181 
182  inline void addTriggers(immer::flex_vector<KazvEvent> c) {
183  nextTriggers = std::move(nextTriggers) + c;
184  }
185 
186  inline auto popAllTriggers() {
187  auto triggers = std::move(nextTriggers);
189  return triggers;
190  }
191 
195 
196  static Result update(ClientModel m, Action a);
197  };
198 
199  // actions:
200  struct LoginAction {
201  std::string serverUrl;
202  std::string username;
203  std::string password;
204  std::optional<std::string> deviceName;
205  };
206 
208  {
209  std::string serverUrl;
210  std::string username;
211  std::string token;
212  std::string deviceId;
213  };
214 
215  struct LogoutAction {};
216 
218  {
219  std::string userId;
220  };
221 
223  {
224  std::string serverUrl;
225  };
226 
227  struct SyncAction {};
228 
230  {
232  };
233 
235  {
236  std::string roomId;
238  std::string fromEventId;
239  std::optional<int> limit;
240  };
241 
243  {
244  std::string roomId;
246  std::optional<std::string> txnId{std::nullopt};
247  };
248 
250  {
251  std::string roomId;
253  };
254 
263  {
265  std::string roomId;
269  std::optional<std::string> txnId{std::nullopt};
270  };
271 
279  {
281  std::string roomId;
283  std::string txnId;
286  };
287 
289  {
290  std::string roomId;
291  std::string eventId;
292  std::optional<std::string> reason;
293  };
294 
296  {
300  std::optional<std::string> roomAliasName;
301  std::optional<std::string> name;
302  std::optional<std::string> topic;
303  immer::array<std::string> invite;
304  //immer::array<Invite3pid> invite3pid;
305  std::optional<std::string> roomVersion;
307  immer::array<Event> initialState;
308  std::optional<Preset> preset;
309  std::optional<bool> isDirect;
311  };
312 
314  {
315  std::string roomId;
316  };
317 
319  {
320  std::string roomId;
321  std::string type;
322  std::string stateKey;
323  };
324 
326  {
327  std::string roomId;
328  std::string userId;
329  };
330 
332  {
333  std::string roomId;
334  };
335 
337  {
338  std::string roomIdOrAlias;
339  immer::array<std::string> serverName;
340  };
341 
343  {
344  std::string roomId;
345  };
346 
348  {
349  std::string roomId;
350  };
351 
352  struct KickAction
353  {
354  std::string roomId;
355  std::string userId;
356  std::optional<std::string> reason;
357  };
358 
359  struct BanAction
360  {
361  std::string roomId;
362  std::string userId;
363  std::optional<std::string> reason;
364  };
365 
366  struct UnbanAction
367  {
368  std::string roomId;
369  std::string userId;
370  };
371 
373  {
374  std::string roomId;
376  };
377 
379  {
380  std::string roomId;
381  bool typing;
382  std::optional<int> timeoutMs;
383  };
384 
386  {
387  std::string roomId;
388  std::string eventId;
389  };
390 
392  {
393  std::string roomId;
394  std::string eventId;
395  };
396 
398  {
400  std::optional<std::string> filename;
401  std::optional<std::string> contentType;
402  std::string uploadId; // to be used by library users
403  };
404 
406  {
407  std::string mxcUri;
408  std::optional<FileDesc> downloadTo;
409  };
410 
412  {
413  std::string mxcUri;
414  int width;
415  int height;
416  std::optional<ThumbnailResizingMethod> method;
417  std::optional<bool> allowRemote;
418  std::optional<FileDesc> downloadTo;
419  };
420 
422  {
424  };
425 
427  {
429  };
430 
432  {
433  };
434 
436  {
438  };
439 
441  {
443  immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
444  std::optional<std::string> txnId{std::nullopt};
445  };
446 
448  {
449  };
450 
459  {
462  static std::size_t randomSize(std::size_t numToGen);
464  std::size_t numToGen;
467  };
468 
470  {
472  };
473 
475  {
476  static std::size_t randomSize(immer::map<std::string, immer::flex_vector<std::string>> devicesToSend);
477  std::string roomId;
478  std::string sessionId;
479  std::string sessionKey;
480  immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
482  };
483 
503  {
504  static std::size_t maxRandomSize();
505  static std::size_t minRandomSize();
506 
508  std::string roomId;
517  };
518 
527  {
528  using UserIdToDeviceIdMap = immer::map<std::string, immer::flex_vector<std::string>>;
529  static std::size_t randomSize(UserIdToDeviceIdMap devices);
530 
538  };
539 
541  {
542  std::string userId;
543  std::string deviceId;
545  };
546 
548  {
550  };
551 
556  {
557  using UserIdToDeviceIdMap = immer::map<std::string, immer::flex_vector<std::string>>;
558 
560  std::string roomId;
568  };
569 
571  {
572  std::string userId;
573  };
574 
576  {
577  std::optional<std::string> avatarUrl;
578  };
579 
581  {
582  std::optional<std::string> displayName;
583  };
584 
585  template<class Archive>
586  void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
587  {
588  bool dummySyncing{false};
589  ar
590  & m.serverUrl
591  & m.userId
592  & m.token
593  & m.deviceId
594  & m.loggedIn
595 
596  & dummySyncing
597  & m.firstRetryMs
598  & m.retryTimeFactor
599  & m.maxRetryMs
600  & m.syncTimeoutMs
603  & m.syncToken
604 
605  & m.roomList
606  & m.presence
607  & m.accountData
608 
609  & m.nextTxnId
610 
611  & m.toDevice;
612  // version <= 1 uses std::optional<Crypto>
613  // while version >= 2 uses std::optional<immer::box<Crypto>>
614  if (version >= 2) {
615  ar & m.crypto;
616  } else {
617  if constexpr (typename Archive::is_loading()) {
618  std::optional<Crypto> crypto;
619  ar >> crypto;
620  if (crypto.has_value()) {
621  m.crypto = immer::box<Crypto>(std::move(crypto).value());
622  }
623  }
624  // otherwise is_saving, which will always use the latest version
625  // this is unreachable
626  }
627 
628  ar
630 
631  & m.deviceLists
632  ;
633 
634  if (version >= 1) { ar & m.trustLevelNeededToSendKeys; }
635  }
636 }
637 
638 BOOST_CLASS_VERSION(Kazv::ClientModel, 2)
Kazv::GetStateEventAction::roomId
std::string roomId
Definition: client-model.hpp:320
Kazv::ForgetRoomAction::roomId
std::string roomId
Definition: client-model.hpp:349
Kazv::SetTypingAction
Definition: client-model.hpp:378
Kazv::JoinRoomAction::roomIdOrAlias
std::string roomIdOrAlias
Definition: client-model.hpp:338
room-model.hpp
Kazv::ClientModel::incrementalSyncFilterId
std::string incrementalSyncFilterId
Definition: client-model.hpp:73
Kazv::SetDisplayNameAction
Definition: client-model.hpp:580
Kazv::DownloadThumbnailAction::height
int height
Definition: client-model.hpp:415
Kazv::UpdateLocalEchoStatusAction::roomId
std::string roomId
The room id.
Definition: client-model.hpp:281
Kazv::ClaimKeysAction::sessionId
std::string sessionId
Definition: client-model.hpp:478
Kazv::ClaimKeysAction::roomId
std::string roomId
Definition: client-model.hpp:477
Kazv::CreateRoomAction::roomVersion
std::optional< std::string > roomVersion
Definition: client-model.hpp:305
Kazv::SetDisplayNameAction::displayName
std::optional< std::string > displayName
Definition: client-model.hpp:582
Kazv::ClientModel::job
constexpr auto job() const
Definition: client-model.hpp:164
Kazv::SetAccountDataPerRoomAction::roomId
std::string roomId
Definition: client-model.hpp:374
Kazv::UpdateLocalEchoStatusAction
Updates the status of an local echo.
Definition: client-model.hpp:278
Kazv::RandomData
std::string RandomData
Definition: crypto-util.hpp:35
Kazv::GenerateAndUploadOneTimeKeysAction
The action to generate one-time keys.
Definition: client-model.hpp:458
immer-box.hpp
Kazv::ClaimKeysAction::randomSize
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string >> devicesToSend)
Definition: client-model.cpp:291
Kazv::ClientModel::directRoomMap
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition: client-model.cpp:354
Kazv::PrepareForSharingRoomKeyAction::devices
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition: client-model.hpp:562
Kazv::UnbanAction::roomId
std::string roomId
Definition: client-model.hpp:368
Kazv::EncryptMegOlmEventAction::e
Event e
The event to encrypt.
Definition: client-model.hpp:510
Kazv::ClientModel::trustLevelNeededToSendKeys
DeviceTrustLevel trustLevelNeededToSendKeys
Definition: client-model.hpp:89
Kazv::LoginAction::password
std::string password
Definition: client-model.hpp:203
Kazv::EncryptOlmEventAction::randomSize
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition: client-model.cpp:278
Kazv::PostReceiptAction::roomId
std::string roomId
Definition: client-model.hpp:387
Kazv::ClientModel::userId
std::string userId
Definition: client-model.hpp:61
Kazv::SendToDeviceMessageAction::txnId
std::optional< std::string > txnId
Definition: client-model.hpp:444
Kazv::GetVersionsAction::serverUrl
std::string serverUrl
Definition: client-model.hpp:224
Kazv::Scale
@ Scale
Definition: client-model.hpp:55
Kazv::KickAction::userId
std::string userId
Definition: client-model.hpp:355
Kazv::UpdateLocalEchoStatusAction::txnId
std::string txnId
The chosen txnId for this event.
Definition: client-model.hpp:283
Kazv::EncryptOlmEventAction
The action to encrypt events with olm for multiple devices.
Definition: client-model.hpp:526
Kazv::TokenLoginAction::username
std::string username
Definition: client-model.hpp:210
Kazv::GetStateEventAction::stateKey
std::string stateKey
Definition: client-model.hpp:322
Kazv::EncryptOlmEventAction::e
Event e
The event to encrypt.
Definition: client-model.hpp:534
Kazv::ClientModel::MakeJobT
Definition: client-model.hpp:143
Kazv::ClientModel::accountData
immer::map< std::string, Event > accountData
Definition: client-model.hpp:78
Kazv::SetDeviceTrustLevelAction::deviceId
std::string deviceId
Definition: client-model.hpp:543
Kazv::SetAccountDataAction
Definition: client-model.hpp:435
Kazv::CreateRoomAction::name
std::optional< std::string > name
Definition: client-model.hpp:301
Kazv::SyncAction
Definition: client-model.hpp:227
Kazv::ClientModel::loggedIn
bool loggedIn
Definition: client-model.hpp:64
Kazv::CreateRoomAction::invite
immer::array< std::string > invite
Definition: client-model.hpp:303
Kazv::UnbanAction::userId
std::string userId
Definition: client-model.hpp:369
Kazv::UploadIdentityKeysAction
Definition: client-model.hpp:447
Kazv::ClientModel::withCrypto
auto withCrypto(Func &&func) -> std::decay_t< std::invoke_result_t< Func &&, Crypto & >>
Do func with crypto, returning its return value.
Definition: client-model.hpp:121
Kazv::ClientModel::roomIdsByTagId
auto roomIdsByTagId() const -> immer::map< std::string, immer::map< std::string, double >>
Definition: client-model.cpp:393
Kazv::InviteToRoomAction::roomId
std::string roomId
Definition: client-model.hpp:327
Kazv::RedactEventAction::roomId
std::string roomId
Definition: client-model.hpp:290
Kazv::SetTrustLevelNeededToSendKeysAction::trustLevel
DeviceTrustLevel trustLevel
Definition: client-model.hpp:549
Kazv::EncryptOlmEventAction::devices
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition: client-model.hpp:532
Kazv::GetRoomStatesAction::roomId
std::string roomId
Definition: client-model.hpp:315
Kazv::BanAction::reason
std::optional< std::string > reason
Definition: client-model.hpp:363
Kazv::SendToDeviceMessageAction::devicesToSend
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition: client-model.hpp:443
Kazv::ClientModel::firstRetryMs
int firstRetryMs
Definition: client-model.hpp:68
Kazv::SetReadMarkerAction::eventId
std::string eventId
Definition: client-model.hpp:394
Kazv::EncryptOlmEventAction::random
RandomData random
The random data for the encryption.
Definition: client-model.hpp:537
Kazv::DownloadThumbnailAction::allowRemote
std::optional< bool > allowRemote
Definition: client-model.hpp:417
Kazv::ClaimKeysAction::random
RandomData random
Definition: client-model.hpp:481
Kazv::ClaimKeysAction
Definition: client-model.hpp:474
Kazv::JoinRoomAction
Definition: client-model.hpp:336
Kazv::QueryKeysAction
Definition: client-model.hpp:469
Kazv::ClientModel::shouldSync
bool shouldSync
Definition: client-model.hpp:67
Kazv::ClientModel::maxRetryMs
int maxRetryMs
Definition: client-model.hpp:70
Kazv::SendMessageAction::event
Event event
Definition: client-model.hpp:245
Kazv::RedactEventAction
Definition: client-model.hpp:288
Kazv::Crop
@ Crop
Definition: client-model.hpp:54
Kazv::ClientModel::addTriggers
void addTriggers(immer::flex_vector< KazvEvent > c)
Definition: client-model.hpp:182
file-desc.hpp
Kazv::Private
@ Private
Definition: client-model.hpp:41
Kazv::CreateRoomAction::roomAliasName
std::optional< std::string > roomAliasName
Definition: client-model.hpp:300
Kazv::LoginAction::serverUrl
std::string serverUrl
Definition: client-model.hpp:201
Kazv::ClientModel::syncToken
std::optional< std::string > syncToken
Definition: client-model.hpp:74
Kazv::SendToDeviceMessageAction
Definition: client-model.hpp:440
Kazv::DownloadThumbnailAction
Definition: client-model.hpp:411
Kazv::ClientModel::deviceId
std::string deviceId
Definition: client-model.hpp:63
Kazv::SetTypingAction::roomId
std::string roomId
Definition: client-model.hpp:380
Kazv::CreateRoomAction::creationContent
JsonWrap creationContent
Definition: client-model.hpp:306
Kazv::ClientModel::crypto
std::optional< immer::box< Crypto > > crypto
Definition: client-model.hpp:85
Kazv::LeaveRoomAction
Definition: client-model.hpp:342
Kazv::CreateRoomAction::powerLevelContentOverride
JsonWrap powerLevelContentOverride
Definition: client-model.hpp:310
Kazv::ClientModel::update
static Result update(ClientModel m, Action a)
Definition: client-model.cpp:40
Kazv
Definition: location.hpp:10
Kazv::Timestamp
std::int_fast64_t Timestamp
Definition: event.hpp:18
Kazv::ClientModel::maybeRotateSessions
void maybeRotateSessions(ClientModel oldClient)
rotate sessions for a room if there is a user in the room with devicesToSendKeys changes
Definition: client-model.cpp:299
Kazv::ClientAction
std::variant< RoomListAction, LoginAction, TokenLoginAction, LogoutAction, GetWellknownAction, GetVersionsAction, SyncAction, SetShouldSyncAction, PostInitialFiltersAction, SetAccountDataAction, PaginateTimelineAction, SendMessageAction, SendStateEventAction, SaveLocalEchoAction, UpdateLocalEchoStatusAction, RedactEventAction, CreateRoomAction, GetRoomStatesAction, GetStateEventAction, InviteToRoomAction, JoinRoomByIdAction, JoinRoomAction, LeaveRoomAction, ForgetRoomAction, KickAction, BanAction, UnbanAction, SetAccountDataPerRoomAction, ProcessResponseAction, SetTypingAction, PostReceiptAction, SetReadMarkerAction, UploadContentAction, DownloadContentAction, DownloadThumbnailAction, SendToDeviceMessageAction, UploadIdentityKeysAction, GenerateAndUploadOneTimeKeysAction, QueryKeysAction, ClaimKeysAction, EncryptMegOlmEventAction, EncryptOlmEventAction, SetDeviceTrustLevelAction, SetTrustLevelNeededToSendKeysAction, PrepareForSharingRoomKeyAction, GetUserProfileAction, SetAvatarUrlAction, SetDisplayNameAction, ResubmitJobAction > ClientAction
Definition: clientfwd.hpp:143
Kazv::UploadContentAction::content
FileDesc content
Definition: client-model.hpp:399
clientfwd.hpp
Kazv::SaveLocalEchoAction
Saves an local echo.
Definition: client-model.hpp:262
Kazv::JoinRoomByIdAction::roomId
std::string roomId
Definition: client-model.hpp:333
Kazv::SetTrustLevelNeededToSendKeysAction
Definition: client-model.hpp:547
Kazv::EncryptMegOlmEventAction::random
RandomData random
Random data for the operation.
Definition: client-model.hpp:516
Kazv::PostInitialFiltersAction
Definition: client-model.hpp:431
Kazv::CreateRoomAction::topic
std::optional< std::string > topic
Definition: client-model.hpp:302
Kazv::EncryptMegOlmEventAction::maxRandomSize
static std::size_t maxRandomSize()
Definition: client-model.cpp:268
Kazv::SendStateEventAction
Definition: client-model.hpp:249
device-list-tracker.hpp
Kazv::ClientModel::nextJobs
immer::flex_vector< BaseJob > nextJobs
Definition: client-model.hpp:81
Kazv::ClientModel::Result
ClientResult Result
Definition: client-model.hpp:194
Kazv::Public
@ Public
Definition: client-model.hpp:42
Kazv::EncryptMegOlmEventAction
The action to encrypt an megolm event for a room.
Definition: client-model.hpp:502
Kazv::DEFTXNID
const std::string DEFTXNID
Definition: client-model.hpp:37
Kazv::PublicChat
@ PublicChat
Definition: client-model.hpp:48
Kazv::ClientModel::syncTimeoutMs
int syncTimeoutMs
Definition: client-model.hpp:71
Kazv::SetAccountDataPerRoomAction
Definition: client-model.hpp:372
Kazv::LoginAction::deviceName
std::optional< std::string > deviceName
Definition: client-model.hpp:204
Kazv::InviteToRoomAction
Definition: client-model.hpp:325
Kazv::ClientModel::Action
ClientAction Action
Definition: client-model.hpp:192
Kazv::SetAvatarUrlAction
Definition: client-model.hpp:575
Kazv::ProcessResponseAction::response
Response response
Definition: client-model.hpp:428
Kazv::GetWellknownAction::userId
std::string userId
Definition: client-model.hpp:219
Kazv::RoomVisibility
RoomVisibility
Definition: client-model.hpp:39
Kazv::KazvEvent
std::variant< std::monostate, ReceivingPresenceEvent, ReceivingAccountDataEvent, ReceivingRoomTimelineEvent, ReceivingRoomStateEvent, RoomMembershipChanged, ReceivingRoomAccountDataEvent, ReceivingToDeviceMessage, LoginSuccessful, LoginFailed, SyncSuccessful, SyncFailed, PostInitialFiltersSuccessful, PostInitialFiltersFailed, PaginateSuccessful, PaginateFailed, CreateRoomSuccessful, CreateRoomFailed, InviteUserSuccessful, InviteUserFailed, JoinRoomSuccessful, JoinRoomFailed, LeaveRoomSuccessful, LeaveRoomFailed, ForgetRoomSuccessful, ForgetRoomFailed, SendMessageSuccessful, SendMessageFailed, SendToDeviceMessageSuccessful, SendToDeviceMessageFailed, InvalidMessageFormat, GetRoomStatesSuccessful, GetRoomStatesFailed, GetStateEventSuccessful, GetStateEventFailed, SendStateEventSuccessful, SendStateEventFailed, SetTypingSuccessful, SetTypingFailed, PostReceiptSuccessful, PostReceiptFailed, SetReadMarkerSuccessful, SetReadMarkerFailed, UploadContentSuccessful, UploadContentFailed, DownloadContentSuccessful, DownloadContentFailed, DownloadThumbnailSuccessful, DownloadThumbnailFailed, UploadIdentityKeysSuccessful, UploadIdentityKeysFailed, UploadOneTimeKeysSuccessful, UploadOneTimeKeysFailed, ClaimKeysSuccessful, ClaimKeysFailed, UnrecognizedResponse, ShouldQueryKeys > KazvEvent
Definition: kazvevents.hpp:390
Kazv::PrepareForSharingRoomKeyAction::e
Event e
The key event to encrypt.
Definition: client-model.hpp:564
Kazv::ClientModel::MakeJobT::make
constexpr auto make(Args &&...args) const
Definition: client-model.hpp:146
Kazv::ClientModel::serverUrl
std::string serverUrl
Definition: client-model.hpp:60
Kazv::PaginateTimelineAction::roomId
std::string roomId
Definition: client-model.hpp:236
Kazv::CreateRoomAction::preset
std::optional< Preset > preset
Definition: client-model.hpp:308
Kazv::ClientModel::constCrypto
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition: client-model.cpp:413
Kazv::QueryKeysAction::isInitialSync
bool isInitialSync
Definition: client-model.hpp:471
Kazv::PrepareForSharingRoomKeyAction::UserIdToDeviceIdMap
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition: client-model.hpp:557
Kazv::GetStateEventAction::type
std::string type
Definition: client-model.hpp:321
Kazv::PostReceiptAction
Definition: client-model.hpp:385
Kazv::ClientModel::popAllJobs
auto popAllJobs()
Definition: client-model.hpp:172
Kazv::SetAvatarUrlAction::avatarUrl
std::optional< std::string > avatarUrl
Definition: client-model.hpp:577
Kazv::serialize
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition: client-model.hpp:586
Kazv::DownloadThumbnailAction::downloadTo
std::optional< FileDesc > downloadTo
Definition: client-model.hpp:418
Kazv::ClientModel::devicesToSendKeys
immer::flex_vector< std::string > devicesToSendKeys(std::string userId) const
Definition: client-model.cpp:228
Kazv::CreateRoomPreset
CreateRoomPreset
Definition: client-model.hpp:45
Kazv::DEFVAL
constexpr detail::DefaultValT DEFVAL
Definition: types.hpp:114
Kazv::Unseen
@ Unseen
Definition: device-list-tracker.hpp:29
Kazv::ClientModel::numOneTimeKeysNeeded
std::size_t numOneTimeKeysNeeded() const
Definition: client-model.cpp:252
Kazv::ThumbnailResizingMethod
ThumbnailResizingMethod
Definition: client-model.hpp:52
Kazv::PrepareForSharingRoomKeyAction::roomId
std::string roomId
The room to share the key event in.
Definition: client-model.hpp:560
Kazv::ClientModel::syncing
bool syncing
Definition: client-model.hpp:66
Kazv::UpdateLocalEchoStatusAction::status
LocalEchoDesc::Status status
The updated status of this local echo.
Definition: client-model.hpp:285
Kazv::LoginAction::username
std::string username
Definition: client-model.hpp:202
Kazv::ClientModel::nextTriggers
immer::flex_vector< KazvEvent > nextTriggers
Definition: client-model.hpp:82
Kazv::PostReceiptAction::eventId
std::string eventId
Definition: client-model.hpp:388
Kazv::ClientModel::toDevice
EventList toDevice
Definition: client-model.hpp:84
Kazv::DownloadContentAction::mxcUri
std::string mxcUri
Definition: client-model.hpp:407
Kazv::ClientModel::popAllTriggers
auto popAllTriggers()
Definition: client-model.hpp:186
Kazv::GetRoomStatesAction
Definition: client-model.hpp:313
Kazv::RedactEventAction::reason
std::optional< std::string > reason
Definition: client-model.hpp:292
Kazv::SendStateEventAction::event
Event event
Definition: client-model.hpp:252
Kazv::DownloadThumbnailAction::mxcUri
std::string mxcUri
Definition: client-model.hpp:413
Kazv::KickAction::roomId
std::string roomId
Definition: client-model.hpp:354
Kazv::SetAccountDataPerRoomAction::accountDataEvent
Event accountDataEvent
Definition: client-model.hpp:375
Kazv::EncryptMegOlmEventAction::timeMs
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition: client-model.hpp:512
Kazv::PrepareForSharingRoomKeyAction
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition: client-model.hpp:555
Kazv::ClientModel::token
std::string token
Definition: client-model.hpp:62
Kazv::ClientModel::MakeJobT::token
std::string token
Definition: client-model.hpp:160
Kazv::DeviceListTracker
Definition: device-list-tracker.hpp:58
Kazv::TokenLoginAction::serverUrl
std::string serverUrl
Definition: client-model.hpp:209
Kazv::SendToDeviceMessageAction::event
Event event
Definition: client-model.hpp:442
Kazv::GetVersionsAction
Definition: client-model.hpp:222
Kazv::LoginAction
Definition: client-model.hpp:200
Kazv::ClientResult
std::pair< ClientModel, ClientEffect > ClientResult
Definition: clientfwd.hpp:147
Kazv::JoinRoomByIdAction
Definition: client-model.hpp:331
Kazv::ClientModel::addTrigger
void addTrigger(KazvEvent t)
Definition: client-model.hpp:178
Kazv::SetReadMarkerAction
Definition: client-model.hpp:391
Kazv::JoinRoomAction::serverName
immer::array< std::string > serverName
Definition: client-model.hpp:339
Kazv::GetWellknownAction
Definition: client-model.hpp:217
Kazv::SendMessageAction::txnId
std::optional< std::string > txnId
Definition: client-model.hpp:246
Kazv::Crypto
Definition: crypto.hpp:35
Kazv::ClientModel::retryTimeFactor
int retryTimeFactor
Definition: client-model.hpp:69
Kazv::SetDeviceTrustLevelAction::userId
std::string userId
Definition: client-model.hpp:542
Kazv::JsonWrap
Definition: jsonwrap.hpp:22
Kazv::SendMessageAction
Definition: client-model.hpp:242
Kazv::SaveLocalEchoAction::roomId
std::string roomId
The room id.
Definition: client-model.hpp:265
Kazv::EncryptOlmEventAction::UserIdToDeviceIdMap
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition: client-model.hpp:528
Kazv::TokenLoginAction::deviceId
std::string deviceId
Definition: client-model.hpp:212
Kazv::CreateRoomAction
Definition: client-model.hpp:295
Kazv::ClientEffect
Effect< ClientAction, lager::deps<> > ClientEffect
Definition: clientfwd.hpp:145
Kazv::BanAction::roomId
std::string roomId
Definition: client-model.hpp:361
Kazv::ResubmitJobAction::job
BaseJob job
Definition: client-model.hpp:423
Kazv::ResubmitJobAction
Definition: client-model.hpp:421
Kazv::ClientModel::presence
immer::map< std::string, Event > presence
Definition: client-model.hpp:77
Kazv::UploadContentAction::uploadId
std::string uploadId
Definition: client-model.hpp:402
Kazv::Event
Definition: event.hpp:20
Kazv::ClaimKeysAction::sessionKey
std::string sessionKey
Definition: client-model.hpp:479
Kazv::LeaveRoomAction::roomId
std::string roomId
Definition: client-model.hpp:344
Kazv::GenerateAndUploadOneTimeKeysAction::randomSize
static std::size_t randomSize(std::size_t numToGen)
Definition: client-model.cpp:286
Kazv::PaginateTimelineAction::fromEventId
std::string fromEventId
Must be where the Gap is.
Definition: client-model.hpp:238
Kazv::LocalEchoDesc::Status
Status
Definition: local-echo.hpp:20
Kazv::BaseJob
Definition: basejob.hpp:76
Kazv::KickAction
Definition: client-model.hpp:352
std-optional.hpp
Kazv::EncryptMegOlmEventAction::roomId
std::string roomId
The id of the room to encrypt for.
Definition: client-model.hpp:508
Kazv::SaveLocalEchoAction::event
Event event
The event to send.
Definition: client-model.hpp:267
immer-map.hpp
Kazv::UploadContentAction::contentType
std::optional< std::string > contentType
Definition: client-model.hpp:401
std
Definition: clientutil.hpp:216
Kazv::CreateRoomAction::isDirect
std::optional< bool > isDirect
Definition: client-model.hpp:309
Kazv::SetShouldSyncAction::shouldSync
bool shouldSync
Definition: client-model.hpp:231
Kazv::GenerateAndUploadOneTimeKeysAction::random
RandomData random
The random data used to generate keys.
Definition: client-model.hpp:466
Kazv::PrivateChat
@ PrivateChat
Definition: client-model.hpp:47
Kazv::ClientModel::roomList
RoomListModel roomList
Definition: client-model.hpp:76
Kazv::BanAction
Definition: client-model.hpp:359
Kazv::EffectBase
Definition: context.hpp:204
Kazv::ClientModel::initialSyncFilterId
std::string initialSyncFilterId
Definition: client-model.hpp:72
Kazv::SetReadMarkerAction::roomId
std::string roomId
Definition: client-model.hpp:393
Kazv::DownloadContentAction::downloadTo
std::optional< FileDesc > downloadTo
Definition: client-model.hpp:408
Kazv::ClientModel::nextTxnId
std::string nextTxnId
Definition: client-model.hpp:80
Kazv::SetShouldSyncAction
Definition: client-model.hpp:229
Kazv::SetTypingAction::typing
bool typing
Definition: client-model.hpp:381
Kazv::EncryptMegOlmEventAction::minRandomSize
static std::size_t minRandomSize()
Definition: client-model.cpp:273
Kazv::TrustedPrivateChat
@ TrustedPrivateChat
Definition: client-model.hpp:49
Kazv::FileDesc
Definition: file-desc.hpp:224
Kazv::SendStateEventAction::roomId
std::string roomId
Definition: client-model.hpp:251
Kazv::GetStateEventAction
Definition: client-model.hpp:318
Kazv::GetUserProfileAction::userId
std::string userId
Definition: client-model.hpp:572
Kazv::InviteToRoomAction::userId
std::string userId
Definition: client-model.hpp:328
Kazv::SendMessageAction::roomId
std::string roomId
Definition: client-model.hpp:244
libkazv-config.hpp
immer-flex-vector.hpp
Kazv::ClientModel::megOlmEncrypt
std::pair< Event, std::optional< std::string > > megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random)
Definition: client-model.cpp:124
Kazv::BanAction::userId
std::string userId
Definition: client-model.hpp:362
Kazv::KickAction::reason
std::optional< std::string > reason
Definition: client-model.hpp:356
Kazv::CreateRoomAction::visibility
Visibility visibility
Definition: client-model.hpp:299
Kazv::SetAccountDataAction::accountDataEvent
Event accountDataEvent
Definition: client-model.hpp:437
Kazv::UploadContentAction::filename
std::optional< std::string > filename
Definition: client-model.hpp:400
Kazv::UploadContentAction
Definition: client-model.hpp:397
Kazv::GenerateAndUploadOneTimeKeysAction::numToGen
std::size_t numToGen
The number of keys to generate.
Definition: client-model.hpp:464
Kazv::ClientModel::MakeJobT::serverUrl
std::string serverUrl
Definition: client-model.hpp:159
Kazv::DownloadThumbnailAction::width
int width
Definition: client-model.hpp:414
Kazv::ClaimKeysAction::devicesToSend
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition: client-model.hpp:480
Kazv::PrepareForSharingRoomKeyAction::random
RandomData random
The random data for the encryption.
Definition: client-model.hpp:567
Kazv::RedactEventAction::eventId
std::string eventId
Definition: client-model.hpp:291
Kazv::LogoutAction
Definition: client-model.hpp:215
Kazv::ClientModel::roomIdsUnderTag
auto roomIdsUnderTag(std::string tagId) const -> immer::map< std::string, double >
Definition: client-model.cpp:377
crypto.hpp
Kazv::SaveLocalEchoAction::txnId
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition: client-model.hpp:269
Kazv::SetDeviceTrustLevelAction
Definition: client-model.hpp:540
sync.hpp
Kazv::ClientModel
Definition: client-model.hpp:58
Kazv::RoomListModel
Definition: room-model.hpp:284
Kazv::DownloadThumbnailAction::method
std::optional< ThumbnailResizingMethod > method
Definition: client-model.hpp:416
Kazv::DeviceTrustLevel
DeviceTrustLevel
Definition: device-list-tracker.hpp:26
Kazv::TokenLoginAction::token
std::string token
Definition: client-model.hpp:211
Kazv::EventList
immer::flex_vector< Event > EventList
Definition: types.hpp:96
Kazv::PaginateTimelineAction::limit
std::optional< int > limit
Definition: client-model.hpp:239
Kazv::UnbanAction
Definition: client-model.hpp:366
Kazv::ForgetRoomAction
Definition: client-model.hpp:347
Kazv::PaginateTimelineAction
Definition: client-model.hpp:234
Kazv::GetUserProfileAction
Definition: client-model.hpp:570
Kazv::ProcessResponseAction
Definition: client-model.hpp:426
Kazv::ClientModel::addJob
void addJob(BaseJob j)
Definition: client-model.hpp:168
Kazv::TokenLoginAction
Definition: client-model.hpp:207
Kazv::Response
Definition: basejob.hpp:50
Kazv::SetTypingAction::timeoutMs
std::optional< int > timeoutMs
Definition: client-model.hpp:382
immer-array.hpp
Kazv::SetDeviceTrustLevelAction::trustLevel
DeviceTrustLevel trustLevel
Definition: client-model.hpp:544
Kazv::ClientModel::olmEncrypt
Event olmEncrypt(Event e, immer::map< std::string, immer::flex_vector< std::string >> userIdToDeviceIdMap, RandomData random)
precondition: the one-time keys for those devices must already be claimed
Definition: client-model.cpp:179
Kazv::CreateRoomAction::initialState
immer::array< Event > initialState
Definition: client-model.hpp:307
Kazv::ClientModel::identityKeysUploaded
bool identityKeysUploaded
Definition: client-model.hpp:86
Kazv::DownloadContentAction
Definition: client-model.hpp:405
Kazv::ClientModel::deviceLists
DeviceListTracker deviceLists
Definition: client-model.hpp:88