libkazv
Loading...
Searching...
No Matches
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>
30
31#include "clientfwd.hpp"
33#include "room/room-model.hpp"
34
35namespace Kazv
36{
37 inline const std::string DEFTXNID{"0"};
38
44
51
57
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};
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<KazvTrigger> nextTriggers;
83
85 std::optional<immer::box<Crypto>> crypto;
87
90
91 immer::array<std::string /* version */> versions;
92
93 immer::flex_vector<std::string /* deviceId */> devicesToSendKeys(std::string userId) const;
94
97 void maybeRotateSessions(ClientModel oldClient);
98
99 std::pair<Event, std::optional<std::string> /* sessionKey */>
100 megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random);
101
104 immer::map<std::string, immer::map<std::string, Event>> olmEncryptSplit(Event e, immer::map<std::string, immer::flex_vector<std::string>> userIdToDeviceIdMap, RandomData random, bool attachSenderDeviceKeys = false);
105
108
114 json convertSignature(std::string signature) const;
115
117 std::size_t numOneTimeKeysNeeded() const;
118
120 auto directRoomMap() const -> immer::map<std::string, std::string>;
121
122 auto roomIdsUnderTag(std::string tagId) const -> immer::map<std::string, double>;
123
124 auto roomIdsByTagId() const -> immer::map<std::string, immer::map<std::string, double>>;
125
129 const Crypto &constCrypto() const;
130
134 template<class Func>
135 auto withCrypto(Func &&func) -> std::decay_t<std::invoke_result_t<Func &&, Crypto &>>
136 {
137 using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
138 if constexpr (std::is_same_v<ResT, void>) {
139 crypto = std::move(crypto).value()
140 .update([f=std::forward<Func>(func)](Crypto c) mutable {
141 std::forward<Func>(f)(c);
142 return c;
143 });
144 } else {
145 std::optional<ResT> res;
146 crypto = std::move(crypto).value()
147 .update([f=std::forward<Func>(func), &res](Crypto c) mutable {
148 res = std::forward<Func>(f)(c);
149 return c;
150 });
151 return std::move(res).value();
152 }
153 }
154
155 // helpers
156 template<class Job>
157 struct MakeJobT
158 {
159 template<class ...Args>
160 constexpr auto make(Args &&...args) const {
161 if constexpr (Job::needsAuth()) {
162 return Job(
163 serverUrl,
164 token,
165 std::forward<Args>(args)...);
166 } else {
167 return Job(
168 serverUrl,
169 std::forward<Args>(args)...);
170 }
171 }
172
173 std::string serverUrl;
174 std::string token;
175 };
176
177 template<class Job>
178 constexpr auto job() const {
180 }
181
182 inline void addJob(BaseJob j) {
183 nextJobs = std::move(nextJobs).push_back(std::move(j));
184 }
185
186 inline auto popAllJobs() {
187 auto jobs = std::move(nextJobs);
189 return jobs;
190 };
191
192 inline void addTrigger(KazvTrigger t) {
193 addTriggers({t});
194 }
195
196 inline void addTriggers(immer::flex_vector<KazvTrigger> c) {
197 nextTriggers = std::move(nextTriggers) + c;
198 }
199
200 inline auto popAllTriggers() {
201 auto triggers = std::move(nextTriggers);
203 return triggers;
204 }
205
206 void maybeAddSaveEventsTrigger(const ClientModel &old);
207
211
212 static Result update(ClientModel m, Action a);
213 };
214
215 // actions:
216 struct LoginAction {
217 std::string serverUrl;
218 std::string username;
219 std::string password;
220 std::optional<std::string> deviceName;
221 };
222
224 {
225 std::string serverUrl;
226 std::string username;
227 std::string token;
228 std::string deviceId;
229 };
230
235 {
236 std::string serverUrl;
237 std::string loginToken;
238 std::optional<std::string> deviceName;
239 };
240
241 struct LogoutAction {};
243
245 {
246 std::string userId;
247 };
248
250 {
251 std::string serverUrl;
252 };
253
254 struct SyncAction {};
255
257 {
259 };
260
262 {
263 std::string roomId;
265 std::string fromEventId;
266 std::optional<int> limit;
267 };
268
270 {
271 std::string roomId;
273 std::optional<std::string> txnId{std::nullopt};
274 };
275
277 {
278 std::string roomId;
280 };
281
290 {
292 std::string roomId;
296 std::optional<std::string> txnId{std::nullopt};
297 };
298
314
316 {
317 std::string roomId;
318 std::string eventId;
319 std::optional<std::string> reason;
320 };
321
323 {
327 std::optional<std::string> roomAliasName;
328 std::optional<std::string> name;
329 std::optional<std::string> topic;
330 immer::array<std::string> invite;
331 //immer::array<Invite3pid> invite3pid;
332 std::optional<std::string> roomVersion;
334 immer::array<Event> initialState;
335 std::optional<Preset> preset;
336 std::optional<bool> isDirect;
338 };
339
341 {
342 std::string roomId;
343 };
344
346 {
347 std::string roomId;
348 std::string type;
349 std::string stateKey;
350 };
351
353 {
354 std::string roomId;
355 std::string userId;
356 };
357
359 {
360 std::string roomId;
361 };
362
364 {
365 std::string roomIdOrAlias;
366 immer::array<std::string> serverName;
367 };
368
370 {
371 std::string roomId;
372 };
373
375 {
376 std::string roomId;
377 };
378
380 {
381 std::string roomId;
382 std::string userId;
383 std::optional<std::string> reason;
384 };
385
387 {
388 std::string roomId;
389 std::string userId;
390 std::optional<std::string> reason;
391 };
392
394 {
395 std::string roomId;
396 std::string userId;
397 };
398
404
406 {
407 std::string roomId;
408 bool typing;
409 std::optional<int> timeoutMs;
410 };
411
413 {
414 std::string roomId;
415 std::string eventId;
416 };
417
419 {
420 std::string roomId;
421 std::string eventId;
422 };
423
425 {
427 std::optional<std::string> filename;
428 std::optional<std::string> contentType;
429 std::string uploadId; // to be used by library users
430 };
431
433 {
434 std::string mxcUri;
435 std::optional<FileDesc> downloadTo;
436 };
437
439 {
440 std::string mxcUri;
441 int width;
443 std::optional<ThumbnailResizingMethod> method;
444 std::optional<bool> allowRemote;
445 std::optional<FileDesc> downloadTo;
446 };
447
449 {
451 };
452
457
459 {
460 };
461
466
468 {
470 immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
471 std::optional<std::string> txnId{std::nullopt};
472 };
473
480 {
482 immer::map<std::string, immer::map<std::string, Event>> userToDeviceToEventMap;
484 std::optional<std::string> txnId{std::nullopt};
485 };
486
488 {
489 };
490
499 {
502 static std::size_t randomSize(std::size_t numToGen);
504 std::size_t numToGen;
507 };
508
510 {
512 };
513
539 {
549 immer::map<
550 std::string /* userId */,
551 immer::flex_vector<std::string /* deviceId */>> userIdToDeviceIdsMap;
552 };
553
555 {
556 static std::size_t randomSize(immer::map<std::string, immer::flex_vector<std::string>> devicesToSend);
557 std::string roomId;
558 std::string sessionId;
559 std::string sessionKey;
560 immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
562 };
563
583 {
584 static std::size_t maxRandomSize();
585 static std::size_t minRandomSize();
586
588 std::string roomId;
597 };
598
605
615 {
617 immer::map<
618 std::string /* userId */,
619 immer::map<std::string /* deviceId */, DeviceTrustLevel>> trustLevelMap;
620 };
621
626
631 {
632 using UserIdToDeviceIdMap = immer::map<std::string, immer::flex_vector<std::string>>;
633 static std::size_t randomSize(UserIdToDeviceIdMap devices);
634
636 std::string roomId;
644 };
645
654 {
656 std::string fileContent;
658 std::string password;
659 };
660
665
667 {
668 std::string userId;
669 };
670
672 {
673 std::optional<std::string> avatarUrl;
674 };
675
677 {
678 std::optional<std::string> displayName;
679 };
680
683 {
686 immer::map<std::string, EventList> timelineEvents;
692 immer::map<std::string, EventList> relatedEvents;
693 };
694
698 {
700 immer::map<std::string, std::size_t> roomIdToMaxToKeepMap;
701 };
702
703 template<class Archive>
704 void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
705 {
706 bool dummySyncing{false};
707 ar
708 & m.serverUrl
709 & m.userId
710 & m.token
711 & m.deviceId
712 & m.loggedIn
713
714 & dummySyncing
715 & m.firstRetryMs
717 & m.maxRetryMs
718 & m.syncTimeoutMs
721 & m.syncToken
722
723 & m.roomList
724 & m.presence
725 & m.accountData
726
727 & m.nextTxnId
728
729 & m.toDevice;
730 // version <= 1 uses std::optional<Crypto>
731 // while version >= 2 uses std::optional<immer::box<Crypto>>
732 if (version >= 2) {
733 ar & m.crypto;
734 } else {
735 if constexpr (typename Archive::is_loading()) {
736 std::optional<Crypto> crypto;
737 ar >> crypto;
738 if (crypto.has_value()) {
739 m.crypto = immer::box<Crypto>(std::move(crypto).value());
740 }
741 }
742 // otherwise is_saving, which will always use the latest version
743 // this is unreachable
744 }
745
746 ar
748
749 & m.deviceLists
750 ;
751
752 if (version >= 1) { ar & m.trustLevelNeededToSendKeys; }
753 }
754}
755
756BOOST_CLASS_VERSION(Kazv::ClientModel, 2)
Definition basejob.hpp:68
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
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:162
std::variant< std::monostate, ReceivingPresenceEvent, ReceivingAccountDataEvent, ReceivingRoomTimelineEvent, ReceivingRoomStateEvent, RoomMembershipChanged, ReceivingRoomAccountDataEvent, ReceivingToDeviceMessage, LoginSuccessful, LoginFailed, SaveEventsRequested, VerificationTrackerModelChanged, UnrecognizedResponse > KazvTrigger
Definition kazv-triggers.hpp:103
DeviceTrustLevel
Definition device-list-tracker.hpp:27
@ Unseen
Definition device-list-tracker.hpp:29
std::string RandomData
Definition crypto-util.hpp:35
nlohmann::json json
Definition jsonwrap.hpp:20
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:164
std::variant< RoomListAction, LoginAction, TokenLoginAction, MLoginTokenLoginAction, 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, EnsureKeysFromDevicesAction, ClaimKeysAction, EncryptMegOlmEventAction, SetDeviceTrustLevelAction, SetDevicesTrustLevelsAction, SetTrustLevelNeededToSendKeysAction, PrepareForSharingRoomKeyAction, ImportFromKeyBackupFileAction, NotifyVerificationTrackerModelAction, GetUserProfileAction, SetAvatarUrlAction, SetDisplayNameAction, ResubmitJobAction, LoadEventsFromStorageAction, PurgeRoomTimelineAction > ClientAction
Definition clientfwd.hpp:160
immer::flex_vector< Event > EventList
Definition types.hpp:107
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition client-model.hpp:704
Definition clientutil.hpp:140
Device identity keys.
Definition device_keys.hpp:13
Definition client-model.hpp:387
std::optional< std::string > reason
Definition client-model.hpp:390
std::string roomId
Definition client-model.hpp:388
std::string userId
Definition client-model.hpp:389
Definition client-model.hpp:555
std::string roomId
Definition client-model.hpp:557
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string > > devicesToSend)
Definition client-model.cpp:352
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:560
RandomData random
Definition client-model.hpp:561
std::string sessionId
Definition client-model.hpp:558
std::string sessionKey
Definition client-model.hpp:559
Definition client-model.hpp:158
constexpr auto make(Args &&...args) const
Definition client-model.hpp:160
std::string serverUrl
Definition client-model.hpp:173
std::string token
Definition client-model.hpp:174
Definition client-model.hpp:59
auto popAllTriggers()
Definition client-model.hpp:200
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:135
std::string userId
Definition client-model.hpp:61
void maybeAddSaveEventsTrigger(const ClientModel &old)
Definition client-model.cpp:479
int syncTimeoutMs
Definition client-model.hpp:71
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition client-model.cpp:474
immer::flex_vector< std::string > devicesToSendKeys(std::string userId) const
Definition client-model.cpp:286
int firstRetryMs
Definition client-model.hpp:68
DeviceListTracker deviceLists
Definition client-model.hpp:88
bool identityKeysUploaded
Definition client-model.hpp:86
immer::flex_vector< KazvTrigger > nextTriggers
Definition client-model.hpp:82
int maxRetryMs
Definition client-model.hpp:70
ClientAction Action
Definition client-model.hpp:208
std::optional< immer::box< Crypto > > crypto
Definition client-model.hpp:85
auto popAllJobs()
Definition client-model.hpp:186
immer::map< std::string, Event > presence
Definition client-model.hpp:77
std::size_t numOneTimeKeysNeeded() const
Definition client-model.cpp:310
json convertSignature(std::string signature) const
Convert a signature from Crypto into a json object.
Definition client-model.cpp:277
std::string serverUrl
Definition client-model.hpp:60
auto roomIdsByTagId() const -> immer::map< std::string, immer::map< std::string, double > >
Definition client-model.cpp:454
immer::map< std::string, Event > accountData
Definition client-model.hpp:78
DeviceKeys makeSelfDeviceKeys()
Make a struct of DeviceKeys for identity keys of the current device.
Definition client-model.cpp:251
static Result update(ClientModel m, Action a)
Definition client-model.cpp:41
void addTrigger(KazvTrigger t)
Definition client-model.hpp:192
void addTriggers(immer::flex_vector< KazvTrigger > c)
Definition client-model.hpp:196
immer::map< std::string, immer::map< std::string, Event > > olmEncryptSplit(Event e, immer::map< std::string, immer::flex_vector< std::string > > userIdToDeviceIdMap, RandomData random, bool attachSenderDeviceKeys=false)
precondition: the one-time keys for those devices must already be claimed
Definition client-model.cpp:186
bool shouldSync
Definition client-model.hpp:67
std::string incrementalSyncFilterId
Definition client-model.hpp:73
ClientResult Result
Definition client-model.hpp:210
void addJob(BaseJob j)
Definition client-model.hpp:182
immer::flex_vector< BaseJob > nextJobs
Definition client-model.hpp:81
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition client-model.cpp:415
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:360
std::string initialSyncFilterId
Definition client-model.hpp:72
bool syncing
Definition client-model.hpp:66
std::string token
Definition client-model.hpp:62
std::string nextTxnId
Definition client-model.hpp:80
constexpr auto job() const
Definition client-model.hpp:178
immer::array< std::string > versions
Definition client-model.hpp:91
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:134
auto roomIdsUnderTag(std::string tagId) const -> immer::map< std::string, double >
Definition client-model.cpp:438
std::optional< std::string > syncToken
Definition client-model.hpp:74
std::string deviceId
Definition client-model.hpp:63
Definition client-model.hpp:323
std::optional< std::string > name
Definition client-model.hpp:328
JsonWrap creationContent
Definition client-model.hpp:333
immer::array< std::string > invite
Definition client-model.hpp:330
std::optional< Preset > preset
Definition client-model.hpp:335
std::optional< std::string > roomVersion
Definition client-model.hpp:332
std::optional< std::string > roomAliasName
Definition client-model.hpp:327
std::optional< bool > isDirect
Definition client-model.hpp:336
JsonWrap powerLevelContentOverride
Definition client-model.hpp:337
Visibility visibility
Definition client-model.hpp:326
immer::array< Event > initialState
Definition client-model.hpp:334
std::optional< std::string > topic
Definition client-model.hpp:329
Definition device-list-tracker.hpp:58
Definition client-model.hpp:433
std::string mxcUri
Definition client-model.hpp:434
std::optional< FileDesc > downloadTo
Definition client-model.hpp:435
Definition client-model.hpp:439
std::string mxcUri
Definition client-model.hpp:440
std::optional< FileDesc > downloadTo
Definition client-model.hpp:445
std::optional< ThumbnailResizingMethod > method
Definition client-model.hpp:443
std::optional< bool > allowRemote
Definition client-model.hpp:444
int width
Definition client-model.hpp:441
int height
Definition client-model.hpp:442
The action to encrypt an megolm event for a room.
Definition client-model.hpp:583
static std::size_t maxRandomSize()
Definition client-model.cpp:329
static std::size_t minRandomSize()
Definition client-model.cpp:334
Event e
The event to encrypt.
Definition client-model.hpp:590
RandomData random
Random data for the operation.
Definition client-model.hpp:596
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition client-model.hpp:592
std::string roomId
The id of the room to encrypt for.
Definition client-model.hpp:588
Ensure keys from devices of a user.
Definition client-model.hpp:539
immer::map< std::string, immer::flex_vector< std::string > > userIdToDeviceIdsMap
The map detailing the devices of which the keys to be fetched.
Definition client-model.hpp:551
Definition client-model.hpp:375
std::string roomId
Definition client-model.hpp:376
The action to generate one-time keys.
Definition client-model.hpp:499
static std::size_t randomSize(std::size_t numToGen)
Definition client-model.cpp:347
RandomData random
The random data used to generate keys.
Definition client-model.hpp:506
std::size_t numToGen
The number of keys to generate.
Definition client-model.hpp:504
Definition client-model.hpp:341
std::string roomId
Definition client-model.hpp:342
Definition client-model.hpp:346
std::string stateKey
Definition client-model.hpp:349
std::string type
Definition client-model.hpp:348
std::string roomId
Definition client-model.hpp:347
Definition client-model.hpp:667
std::string userId
Definition client-model.hpp:668
Definition client-model.hpp:250
std::string serverUrl
Definition client-model.hpp:251
Definition client-model.hpp:245
std::string userId
Definition client-model.hpp:246
Definition client-model.hpp:242
Import keys from key backup file.
Definition client-model.hpp:654
std::string fileContent
The content of the key backup file.
Definition client-model.hpp:656
std::string password
The password.
Definition client-model.hpp:658
Definition client-model.hpp:353
std::string userId
Definition client-model.hpp:355
std::string roomId
Definition client-model.hpp:354
Definition client-model.hpp:364
immer::array< std::string > serverName
Definition client-model.hpp:366
std::string roomIdOrAlias
Definition client-model.hpp:365
Definition client-model.hpp:359
std::string roomId
Definition client-model.hpp:360
Definition client-model.hpp:380
std::string roomId
Definition client-model.hpp:381
std::string userId
Definition client-model.hpp:382
std::optional< std::string > reason
Definition client-model.hpp:383
Definition client-model.hpp:370
std::string roomId
Definition client-model.hpp:371
Load events from the storage into the model.
Definition client-model.hpp:683
immer::map< std::string, EventList > relatedEvents
Map from room id to a list of related events that should not be put into the timeline.
Definition client-model.hpp:692
immer::map< std::string, EventList > timelineEvents
Map from room id to a list of loaded events that should be put into the timeline.
Definition client-model.hpp:686
Status
Definition local-echo.hpp:21
Definition client-model.hpp:216
std::string password
Definition client-model.hpp:219
std::string serverUrl
Definition client-model.hpp:217
std::string username
Definition client-model.hpp:218
std::optional< std::string > deviceName
Definition client-model.hpp:220
Definition client-model.hpp:241
Login using the m.token.login flow.
Definition client-model.hpp:235
std::string loginToken
Definition client-model.hpp:237
std::string serverUrl
Definition client-model.hpp:236
std::optional< std::string > deviceName
Definition client-model.hpp:238
Notify that the verification tracker model has been changed.
Definition client-model.hpp:664
Definition client-model.hpp:262
std::string fromEventId
Must be where the Gap is.
Definition client-model.hpp:265
std::optional< int > limit
Definition client-model.hpp:266
std::string roomId
Definition client-model.hpp:263
Definition client-model.hpp:459
Definition client-model.hpp:413
std::string eventId
Definition client-model.hpp:415
std::string roomId
Definition client-model.hpp:414
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition client-model.hpp:631
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition client-model.hpp:632
Event e
The key event to encrypt.
Definition client-model.hpp:640
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition client-model.hpp:638
std::string roomId
The room to share the key event in.
Definition client-model.hpp:636
RandomData random
The random data for the encryption.
Definition client-model.hpp:643
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition client-model.cpp:339
Definition client-model.hpp:454
Response response
Definition client-model.hpp:455
Remove events from the model, keeping only the latest maxToKeep events.
Definition client-model.hpp:698
immer::map< std::string, std::size_t > roomIdToMaxToKeepMap
A map from roomId to maxToKeep.
Definition client-model.hpp:700
Definition client-model.hpp:510
bool isInitialSync
Definition client-model.hpp:511
Definition client-model.hpp:316
std::string eventId
Definition client-model.hpp:318
std::optional< std::string > reason
Definition client-model.hpp:319
std::string roomId
Definition client-model.hpp:317
Definition basejob.hpp:49
Definition client-model.hpp:449
BaseJob job
Definition client-model.hpp:450
Definition room-model.hpp:450
Saves an local echo.
Definition client-model.hpp:290
std::string roomId
The room id.
Definition client-model.hpp:292
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition client-model.hpp:296
Event event
The event to send.
Definition client-model.hpp:294
Definition client-model.hpp:270
std::optional< std::string > txnId
Definition client-model.hpp:273
std::string roomId
Definition client-model.hpp:271
Event event
Definition client-model.hpp:272
Send multiple to device messages.
Definition client-model.hpp:480
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition client-model.hpp:484
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:482
Definition client-model.hpp:277
Event event
Definition client-model.hpp:279
std::string roomId
Definition client-model.hpp:278
Definition client-model.hpp:468
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:470
std::optional< std::string > txnId
Definition client-model.hpp:471
Event event
Definition client-model.hpp:469
Definition client-model.hpp:463
Event accountDataEvent
Definition client-model.hpp:464
Definition client-model.hpp:400
std::string roomId
Definition client-model.hpp:401
Event accountDataEvent
Definition client-model.hpp:402
Definition client-model.hpp:672
std::optional< std::string > avatarUrl
Definition client-model.hpp:673
Definition client-model.hpp:600
std::string userId
Definition client-model.hpp:601
DeviceTrustLevel trustLevel
Definition client-model.hpp:603
std::string deviceId
Definition client-model.hpp:602
Set the trust levels of devices.
Definition client-model.hpp:615
immer::map< std::string, immer::map< std::string, DeviceTrustLevel > > trustLevelMap
A map from userId to deviceId to the trust level to set.
Definition client-model.hpp:619
Definition client-model.hpp:677
std::optional< std::string > displayName
Definition client-model.hpp:678
Definition client-model.hpp:419
std::string eventId
Definition client-model.hpp:421
std::string roomId
Definition client-model.hpp:420
Definition client-model.hpp:257
bool shouldSync
Definition client-model.hpp:258
Definition client-model.hpp:623
DeviceTrustLevel trustLevel
Definition client-model.hpp:624
Definition client-model.hpp:406
bool typing
Definition client-model.hpp:408
std::optional< int > timeoutMs
Definition client-model.hpp:409
std::string roomId
Definition client-model.hpp:407
Definition client-model.hpp:254
Definition client-model.hpp:224
std::string username
Definition client-model.hpp:226
std::string serverUrl
Definition client-model.hpp:225
std::string deviceId
Definition client-model.hpp:228
std::string token
Definition client-model.hpp:227
Definition client-model.hpp:394
std::string roomId
Definition client-model.hpp:395
std::string userId
Definition client-model.hpp:396
Updates the status of an local echo.
Definition client-model.hpp:306
std::string roomId
The room id.
Definition client-model.hpp:308
LocalEchoDesc::Status status
The updated status of this local echo.
Definition client-model.hpp:312
std::string txnId
The chosen txnId for this event.
Definition client-model.hpp:310
Definition client-model.hpp:425
std::string uploadId
Definition client-model.hpp:429
std::optional< std::string > contentType
Definition client-model.hpp:428
std::optional< std::string > filename
Definition client-model.hpp:427
FileDesc content
Definition client-model.hpp:426
Definition client-model.hpp:488