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);
99 
102  immer::map<std::string, immer::map<std::string, Event>> olmEncryptSplit(Event e, immer::map<std::string, immer::flex_vector<std::string>> userIdToDeviceIdMap, RandomData random);
103 
105  std::size_t numOneTimeKeysNeeded() const;
106 
108  auto directRoomMap() const -> immer::map<std::string, std::string>;
109 
110  auto roomIdsUnderTag(std::string tagId) const -> immer::map<std::string, double>;
111 
112  auto roomIdsByTagId() const -> immer::map<std::string, immer::map<std::string, double>>;
113 
117  const Crypto &constCrypto() const;
118 
122  template<class Func>
123  auto withCrypto(Func &&func) -> std::decay_t<std::invoke_result_t<Func &&, Crypto &>>
124  {
125  using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
126  if constexpr (std::is_same_v<ResT, void>) {
127  crypto = std::move(crypto).value()
128  .update([f=std::forward<Func>(func)](Crypto c) mutable {
129  std::forward<Func>(f)(c);
130  return c;
131  });
132  } else {
133  std::optional<ResT> res;
134  crypto = std::move(crypto).value()
135  .update([f=std::forward<Func>(func), &res](Crypto c) mutable {
136  res = std::forward<Func>(f)(c);
137  return c;
138  });
139  return std::move(res).value();
140  }
141  }
142 
143  // helpers
144  template<class Job>
145  struct MakeJobT
146  {
147  template<class ...Args>
148  constexpr auto make(Args &&...args) const {
149  if constexpr (Job::needsAuth()) {
150  return Job(
151  serverUrl,
152  token,
153  std::forward<Args>(args)...);
154  } else {
155  return Job(
156  serverUrl,
157  std::forward<Args>(args)...);
158  }
159  }
160 
161  std::string serverUrl;
162  std::string token;
163  };
164 
165  template<class Job>
166  constexpr auto job() const {
167  return MakeJobT<Job>{serverUrl, token};
168  }
169 
170  inline void addJob(BaseJob j) {
171  nextJobs = std::move(nextJobs).push_back(std::move(j));
172  }
173 
174  inline auto popAllJobs() {
175  auto jobs = std::move(nextJobs);
176  nextJobs = DEFVAL;
177  return jobs;
178  };
179 
180  inline void addTrigger(KazvEvent t) {
181  addTriggers({t});
182  }
183 
184  inline void addTriggers(immer::flex_vector<KazvEvent> c) {
185  nextTriggers = std::move(nextTriggers) + c;
186  }
187 
188  inline auto popAllTriggers() {
189  auto triggers = std::move(nextTriggers);
191  return triggers;
192  }
193 
197 
198  static Result update(ClientModel m, Action a);
199  };
200 
201  // actions:
202  struct LoginAction {
203  std::string serverUrl;
204  std::string username;
205  std::string password;
206  std::optional<std::string> deviceName;
207  };
208 
210  {
211  std::string serverUrl;
212  std::string username;
213  std::string token;
214  std::string deviceId;
215  };
216 
217  struct LogoutAction {};
218  struct HardLogoutAction {};
219 
221  {
222  std::string userId;
223  };
224 
226  {
227  std::string serverUrl;
228  };
229 
230  struct SyncAction {};
231 
233  {
235  };
236 
238  {
239  std::string roomId;
241  std::string fromEventId;
242  std::optional<int> limit;
243  };
244 
246  {
247  std::string roomId;
249  std::optional<std::string> txnId{std::nullopt};
250  };
251 
253  {
254  std::string roomId;
256  };
257 
266  {
268  std::string roomId;
272  std::optional<std::string> txnId{std::nullopt};
273  };
274 
282  {
284  std::string roomId;
286  std::string txnId;
289  };
290 
292  {
293  std::string roomId;
294  std::string eventId;
295  std::optional<std::string> reason;
296  };
297 
299  {
303  std::optional<std::string> roomAliasName;
304  std::optional<std::string> name;
305  std::optional<std::string> topic;
306  immer::array<std::string> invite;
307  //immer::array<Invite3pid> invite3pid;
308  std::optional<std::string> roomVersion;
310  immer::array<Event> initialState;
311  std::optional<Preset> preset;
312  std::optional<bool> isDirect;
314  };
315 
317  {
318  std::string roomId;
319  };
320 
322  {
323  std::string roomId;
324  std::string type;
325  std::string stateKey;
326  };
327 
329  {
330  std::string roomId;
331  std::string userId;
332  };
333 
335  {
336  std::string roomId;
337  };
338 
340  {
341  std::string roomIdOrAlias;
342  immer::array<std::string> serverName;
343  };
344 
346  {
347  std::string roomId;
348  };
349 
351  {
352  std::string roomId;
353  };
354 
355  struct KickAction
356  {
357  std::string roomId;
358  std::string userId;
359  std::optional<std::string> reason;
360  };
361 
362  struct BanAction
363  {
364  std::string roomId;
365  std::string userId;
366  std::optional<std::string> reason;
367  };
368 
369  struct UnbanAction
370  {
371  std::string roomId;
372  std::string userId;
373  };
374 
376  {
377  std::string roomId;
379  };
380 
382  {
383  std::string roomId;
384  bool typing;
385  std::optional<int> timeoutMs;
386  };
387 
389  {
390  std::string roomId;
391  std::string eventId;
392  };
393 
395  {
396  std::string roomId;
397  std::string eventId;
398  };
399 
401  {
403  std::optional<std::string> filename;
404  std::optional<std::string> contentType;
405  std::string uploadId; // to be used by library users
406  };
407 
409  {
410  std::string mxcUri;
411  std::optional<FileDesc> downloadTo;
412  };
413 
415  {
416  std::string mxcUri;
417  int width;
418  int height;
419  std::optional<ThumbnailResizingMethod> method;
420  std::optional<bool> allowRemote;
421  std::optional<FileDesc> downloadTo;
422  };
423 
425  {
427  };
428 
430  {
432  };
433 
435  {
436  };
437 
439  {
441  };
442 
444  {
446  immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
447  std::optional<std::string> txnId{std::nullopt};
448  };
449 
456  {
458  immer::map<std::string, immer::map<std::string, Event>> userToDeviceToEventMap;
460  std::optional<std::string> txnId{std::nullopt};
461  };
462 
464  {
465  };
466 
475  {
478  static std::size_t randomSize(std::size_t numToGen);
480  std::size_t numToGen;
483  };
484 
486  {
488  };
489 
491  {
492  static std::size_t randomSize(immer::map<std::string, immer::flex_vector<std::string>> devicesToSend);
493  std::string roomId;
494  std::string sessionId;
495  std::string sessionKey;
496  immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
498  };
499 
519  {
520  static std::size_t maxRandomSize();
521  static std::size_t minRandomSize();
522 
524  std::string roomId;
533  };
534 
536  {
537  std::string userId;
538  std::string deviceId;
540  };
541 
543  {
545  };
546 
551  {
552  using UserIdToDeviceIdMap = immer::map<std::string, immer::flex_vector<std::string>>;
553  static std::size_t randomSize(UserIdToDeviceIdMap devices);
554 
556  std::string roomId;
564  };
565 
567  {
568  std::string userId;
569  };
570 
572  {
573  std::optional<std::string> avatarUrl;
574  };
575 
577  {
578  std::optional<std::string> displayName;
579  };
580 
581  template<class Archive>
582  void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
583  {
584  bool dummySyncing{false};
585  ar
586  & m.serverUrl
587  & m.userId
588  & m.token
589  & m.deviceId
590  & m.loggedIn
591 
592  & dummySyncing
593  & m.firstRetryMs
594  & m.retryTimeFactor
595  & m.maxRetryMs
596  & m.syncTimeoutMs
599  & m.syncToken
600 
601  & m.roomList
602  & m.presence
603  & m.accountData
604 
605  & m.nextTxnId
606 
607  & m.toDevice;
608  // version <= 1 uses std::optional<Crypto>
609  // while version >= 2 uses std::optional<immer::box<Crypto>>
610  if (version >= 2) {
611  ar & m.crypto;
612  } else {
613  if constexpr (typename Archive::is_loading()) {
614  std::optional<Crypto> crypto;
615  ar >> crypto;
616  if (crypto.has_value()) {
617  m.crypto = immer::box<Crypto>(std::move(crypto).value());
618  }
619  }
620  // otherwise is_saving, which will always use the latest version
621  // this is unreachable
622  }
623 
624  ar
626 
627  & m.deviceLists
628  ;
629 
630  if (version >= 1) { ar & m.trustLevelNeededToSendKeys; }
631  }
632 }
633 
634 BOOST_CLASS_VERSION(Kazv::ClientModel, 2)
Definition: basejob.hpp:77
Definition: crypto.hpp:36
Definition: context.hpp:205
Definition: event.hpp:21
Definition: file-desc.hpp:225
Definition: jsonwrap.hpp:23
Definition: location.hpp:10
std::variant< RoomListAction, LoginAction, TokenLoginAction, LogoutAction, HardLogoutAction, 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, SendMultipleToDeviceMessagesAction, UploadIdentityKeysAction, GenerateAndUploadOneTimeKeysAction, QueryKeysAction, ClaimKeysAction, EncryptMegOlmEventAction, SetDeviceTrustLevelAction, SetTrustLevelNeededToSendKeysAction, PrepareForSharingRoomKeyAction, GetUserProfileAction, SetAvatarUrlAction, SetDisplayNameAction, ResubmitJobAction > ClientAction
Definition: clientfwd.hpp:145
CreateRoomPreset
Definition: client-model.hpp:46
@ TrustedPrivateChat
Definition: client-model.hpp:49
@ PublicChat
Definition: client-model.hpp:48
@ PrivateChat
Definition: client-model.hpp:47
RoomVisibility
Definition: client-model.hpp:40
@ Public
Definition: client-model.hpp:42
@ Private
Definition: client-model.hpp:41
Effect< ClientAction, lager::deps<> > ClientEffect
Definition: clientfwd.hpp:147
DeviceTrustLevel
Definition: device-list-tracker.hpp:27
@ Unseen
Definition: device-list-tracker.hpp:29
std::string RandomData
Definition: crypto-util.hpp:34
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
const std::string DEFTXNID
Definition: client-model.hpp:37
std::int_fast64_t Timestamp
Definition: event.hpp:18
ThumbnailResizingMethod
Definition: client-model.hpp:53
@ Crop
Definition: client-model.hpp:54
@ Scale
Definition: client-model.hpp:55
constexpr detail::DefaultValT DEFVAL
Definition: types.hpp:125
std::pair< ClientModel, ClientEffect > ClientResult
Definition: clientfwd.hpp:149
immer::flex_vector< Event > EventList
Definition: types.hpp:107
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition: client-model.hpp:582
Definition: clientutil.hpp:217
Definition: client-model.hpp:363
std::optional< std::string > reason
Definition: client-model.hpp:366
std::string roomId
Definition: client-model.hpp:364
std::string userId
Definition: client-model.hpp:365
Definition: client-model.hpp:491
std::string roomId
Definition: client-model.hpp:493
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition: client-model.hpp:496
RandomData random
Definition: client-model.hpp:497
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string >> devicesToSend)
Definition: client-model.cpp:299
std::string sessionId
Definition: client-model.hpp:494
std::string sessionKey
Definition: client-model.hpp:495
Definition: client-model.hpp:146
constexpr auto make(Args &&...args) const
Definition: client-model.hpp:148
std::string serverUrl
Definition: client-model.hpp:161
std::string token
Definition: client-model.hpp:162
Definition: client-model.hpp:59
auto popAllTriggers()
Definition: client-model.hpp:188
RoomListModel roomList
Definition: client-model.hpp:76
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:123
std::string userId
Definition: client-model.hpp:61
int syncTimeoutMs
Definition: client-model.hpp:71
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition: client-model.cpp:421
immer::flex_vector< std::string > devicesToSendKeys(std::string userId) const
Definition: client-model.cpp:233
int firstRetryMs
Definition: client-model.hpp:68
DeviceListTracker deviceLists
Definition: client-model.hpp:88
bool identityKeysUploaded
Definition: client-model.hpp:86
int maxRetryMs
Definition: client-model.hpp:70
ClientAction Action
Definition: client-model.hpp:194
std::optional< immer::box< Crypto > > crypto
Definition: client-model.hpp:85
auto popAllJobs()
Definition: client-model.hpp:174
immer::map< std::string, Event > presence
Definition: client-model.hpp:77
std::size_t numOneTimeKeysNeeded() const
Definition: client-model.cpp:257
auto roomIdsByTagId() const -> immer::map< std::string, immer::map< std::string, double >>
Definition: client-model.cpp:401
std::string serverUrl
Definition: client-model.hpp:60
immer::map< std::string, Event > accountData
Definition: client-model.hpp:78
static Result update(ClientModel m, Action a)
Definition: client-model.cpp:40
bool shouldSync
Definition: client-model.hpp:67
void addTrigger(KazvEvent t)
Definition: client-model.hpp:180
std::string incrementalSyncFilterId
Definition: client-model.hpp:73
ClientResult Result
Definition: client-model.hpp:196
void addTriggers(immer::flex_vector< KazvEvent > c)
Definition: client-model.hpp:184
void addJob(BaseJob j)
Definition: client-model.hpp:170
immer::flex_vector< BaseJob > nextJobs
Definition: client-model.hpp:81
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition: client-model.cpp:362
int retryTimeFactor
Definition: client-model.hpp:69
DeviceTrustLevel trustLevelNeededToSendKeys
Definition: client-model.hpp:89
void maybeRotateSessions(ClientModel oldClient)
rotate sessions for a room if there is a user in the room with devicesToSendKeys changes
Definition: client-model.cpp:307
std::string initialSyncFilterId
Definition: client-model.hpp:72
bool syncing
Definition: client-model.hpp:66
immer::flex_vector< KazvEvent > nextTriggers
Definition: client-model.hpp:82
std::string token
Definition: client-model.hpp:62
std::string nextTxnId
Definition: client-model.hpp:80
constexpr auto job() const
Definition: client-model.hpp:166
bool loggedIn
Definition: client-model.hpp:64
EventList toDevice
Definition: client-model.hpp:84
std::pair< Event, std::optional< std::string > > megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random)
Definition: client-model.cpp:125
immer::map< std::string, immer::map< std::string, Event > > olmEncryptSplit(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:177
auto roomIdsUnderTag(std::string tagId) const -> immer::map< std::string, double >
Definition: client-model.cpp:385
std::optional< std::string > syncToken
Definition: client-model.hpp:74
std::string deviceId
Definition: client-model.hpp:63
Definition: client-model.hpp:299
std::optional< std::string > name
Definition: client-model.hpp:304
JsonWrap creationContent
Definition: client-model.hpp:309
immer::array< std::string > invite
Definition: client-model.hpp:306
std::optional< Preset > preset
Definition: client-model.hpp:311
std::optional< std::string > roomVersion
Definition: client-model.hpp:308
std::optional< std::string > roomAliasName
Definition: client-model.hpp:303
std::optional< bool > isDirect
Definition: client-model.hpp:312
JsonWrap powerLevelContentOverride
Definition: client-model.hpp:313
Visibility visibility
Definition: client-model.hpp:302
immer::array< Event > initialState
Definition: client-model.hpp:310
std::optional< std::string > topic
Definition: client-model.hpp:305
Definition: device-list-tracker.hpp:59
Definition: client-model.hpp:409
std::string mxcUri
Definition: client-model.hpp:410
std::optional< FileDesc > downloadTo
Definition: client-model.hpp:411
Definition: client-model.hpp:415
std::string mxcUri
Definition: client-model.hpp:416
std::optional< FileDesc > downloadTo
Definition: client-model.hpp:421
std::optional< ThumbnailResizingMethod > method
Definition: client-model.hpp:419
std::optional< bool > allowRemote
Definition: client-model.hpp:420
int width
Definition: client-model.hpp:417
int height
Definition: client-model.hpp:418
The action to encrypt an megolm event for a room.
Definition: client-model.hpp:519
static std::size_t maxRandomSize()
Definition: client-model.cpp:276
static std::size_t minRandomSize()
Definition: client-model.cpp:281
Event e
The event to encrypt.
Definition: client-model.hpp:526
RandomData random
Random data for the operation.
Definition: client-model.hpp:532
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition: client-model.hpp:528
std::string roomId
The id of the room to encrypt for.
Definition: client-model.hpp:524
Definition: client-model.hpp:351
std::string roomId
Definition: client-model.hpp:352
The action to generate one-time keys.
Definition: client-model.hpp:475
static std::size_t randomSize(std::size_t numToGen)
Definition: client-model.cpp:294
RandomData random
The random data used to generate keys.
Definition: client-model.hpp:482
std::size_t numToGen
The number of keys to generate.
Definition: client-model.hpp:480
Definition: client-model.hpp:317
std::string roomId
Definition: client-model.hpp:318
Definition: client-model.hpp:322
std::string stateKey
Definition: client-model.hpp:325
std::string type
Definition: client-model.hpp:324
std::string roomId
Definition: client-model.hpp:323
Definition: client-model.hpp:567
std::string userId
Definition: client-model.hpp:568
Definition: client-model.hpp:226
std::string serverUrl
Definition: client-model.hpp:227
Definition: client-model.hpp:221
std::string userId
Definition: client-model.hpp:222
Definition: client-model.hpp:218
Definition: client-model.hpp:329
std::string userId
Definition: client-model.hpp:331
std::string roomId
Definition: client-model.hpp:330
Definition: client-model.hpp:340
immer::array< std::string > serverName
Definition: client-model.hpp:342
std::string roomIdOrAlias
Definition: client-model.hpp:341
Definition: client-model.hpp:335
std::string roomId
Definition: client-model.hpp:336
Definition: client-model.hpp:356
std::string roomId
Definition: client-model.hpp:357
std::string userId
Definition: client-model.hpp:358
std::optional< std::string > reason
Definition: client-model.hpp:359
Definition: client-model.hpp:346
std::string roomId
Definition: client-model.hpp:347
Status
Definition: local-echo.hpp:21
Definition: client-model.hpp:202
std::string password
Definition: client-model.hpp:205
std::string serverUrl
Definition: client-model.hpp:203
std::string username
Definition: client-model.hpp:204
std::optional< std::string > deviceName
Definition: client-model.hpp:206
Definition: client-model.hpp:217
Definition: client-model.hpp:238
std::string fromEventId
Must be where the Gap is.
Definition: client-model.hpp:241
std::optional< int > limit
Definition: client-model.hpp:242
std::string roomId
Definition: client-model.hpp:239
Definition: client-model.hpp:435
Definition: client-model.hpp:389
std::string eventId
Definition: client-model.hpp:391
std::string roomId
Definition: client-model.hpp:390
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition: client-model.hpp:551
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition: client-model.hpp:552
Event e
The key event to encrypt.
Definition: client-model.hpp:560
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition: client-model.hpp:558
std::string roomId
The room to share the key event in.
Definition: client-model.hpp:556
RandomData random
The random data for the encryption.
Definition: client-model.hpp:563
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition: client-model.cpp:286
Definition: client-model.hpp:430
Response response
Definition: client-model.hpp:431
Definition: client-model.hpp:486
bool isInitialSync
Definition: client-model.hpp:487
Definition: client-model.hpp:292
std::string eventId
Definition: client-model.hpp:294
std::optional< std::string > reason
Definition: client-model.hpp:295
std::string roomId
Definition: client-model.hpp:293
Definition: basejob.hpp:50
Definition: client-model.hpp:425
BaseJob job
Definition: client-model.hpp:426
Definition: room-model.hpp:398
Saves an local echo.
Definition: client-model.hpp:266
std::string roomId
The room id.
Definition: client-model.hpp:268
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition: client-model.hpp:272
Event event
The event to send.
Definition: client-model.hpp:270
Definition: client-model.hpp:246
std::optional< std::string > txnId
Definition: client-model.hpp:249
std::string roomId
Definition: client-model.hpp:247
Event event
Definition: client-model.hpp:248
Send multiple to device messages.
Definition: client-model.hpp:456
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition: client-model.hpp:460
immer::map< std::string, immer::map< std::string, Event > > userToDeviceToEventMap
A map from user id to device id to the event.
Definition: client-model.hpp:458
Definition: client-model.hpp:253
Event event
Definition: client-model.hpp:255
std::string roomId
Definition: client-model.hpp:254
Definition: client-model.hpp:444
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition: client-model.hpp:446
std::optional< std::string > txnId
Definition: client-model.hpp:447
Event event
Definition: client-model.hpp:445
Definition: client-model.hpp:439
Event accountDataEvent
Definition: client-model.hpp:440
Definition: client-model.hpp:376
std::string roomId
Definition: client-model.hpp:377
Event accountDataEvent
Definition: client-model.hpp:378
Definition: client-model.hpp:572
std::optional< std::string > avatarUrl
Definition: client-model.hpp:573
Definition: client-model.hpp:536
std::string userId
Definition: client-model.hpp:537
DeviceTrustLevel trustLevel
Definition: client-model.hpp:539
std::string deviceId
Definition: client-model.hpp:538
Definition: client-model.hpp:577
std::optional< std::string > displayName
Definition: client-model.hpp:578
Definition: client-model.hpp:395
std::string eventId
Definition: client-model.hpp:397
std::string roomId
Definition: client-model.hpp:396
Definition: client-model.hpp:233
bool shouldSync
Definition: client-model.hpp:234
Definition: client-model.hpp:543
DeviceTrustLevel trustLevel
Definition: client-model.hpp:544
Definition: client-model.hpp:382
bool typing
Definition: client-model.hpp:384
std::optional< int > timeoutMs
Definition: client-model.hpp:385
std::string roomId
Definition: client-model.hpp:383
Definition: client-model.hpp:230
Definition: client-model.hpp:210
std::string username
Definition: client-model.hpp:212
std::string serverUrl
Definition: client-model.hpp:211
std::string deviceId
Definition: client-model.hpp:214
std::string token
Definition: client-model.hpp:213
Definition: client-model.hpp:370
std::string roomId
Definition: client-model.hpp:371
std::string userId
Definition: client-model.hpp:372
Updates the status of an local echo.
Definition: client-model.hpp:282
std::string roomId
The room id.
Definition: client-model.hpp:284
LocalEchoDesc::Status status
The updated status of this local echo.
Definition: client-model.hpp:288
std::string txnId
The chosen txnId for this event.
Definition: client-model.hpp:286
Definition: client-model.hpp:401
std::string uploadId
Definition: client-model.hpp:405
std::optional< std::string > contentType
Definition: client-model.hpp:404
std::optional< std::string > filename
Definition: client-model.hpp:403
FileDesc content
Definition: client-model.hpp:402
Definition: client-model.hpp:464