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);
105
107 std::size_t numOneTimeKeysNeeded() const;
108
110 auto directRoomMap() const -> immer::map<std::string, std::string>;
111
112 auto roomIdsUnderTag(std::string tagId) const -> immer::map<std::string, double>;
113
114 auto roomIdsByTagId() const -> immer::map<std::string, immer::map<std::string, double>>;
115
119 const Crypto &constCrypto() const;
120
124 template<class Func>
125 auto withCrypto(Func &&func) -> std::decay_t<std::invoke_result_t<Func &&, Crypto &>>
126 {
127 using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
128 if constexpr (std::is_same_v<ResT, void>) {
129 crypto = std::move(crypto).value()
130 .update([f=std::forward<Func>(func)](Crypto c) mutable {
131 std::forward<Func>(f)(c);
132 return c;
133 });
134 } else {
135 std::optional<ResT> res;
136 crypto = std::move(crypto).value()
137 .update([f=std::forward<Func>(func), &res](Crypto c) mutable {
138 res = std::forward<Func>(f)(c);
139 return c;
140 });
141 return std::move(res).value();
142 }
143 }
144
145 // helpers
146 template<class Job>
147 struct MakeJobT
148 {
149 template<class ...Args>
150 constexpr auto make(Args &&...args) const {
151 if constexpr (Job::needsAuth()) {
152 return Job(
153 serverUrl,
154 token,
155 std::forward<Args>(args)...);
156 } else {
157 return Job(
158 serverUrl,
159 std::forward<Args>(args)...);
160 }
161 }
162
163 std::string serverUrl;
164 std::string token;
165 };
166
167 template<class Job>
168 constexpr auto job() const {
170 }
171
172 inline void addJob(BaseJob j) {
173 nextJobs = std::move(nextJobs).push_back(std::move(j));
174 }
175
176 inline auto popAllJobs() {
177 auto jobs = std::move(nextJobs);
179 return jobs;
180 };
181
182 inline void addTrigger(KazvTrigger t) {
183 addTriggers({t});
184 }
185
186 inline void addTriggers(immer::flex_vector<KazvTrigger> c) {
187 nextTriggers = std::move(nextTriggers) + c;
188 }
189
190 inline auto popAllTriggers() {
191 auto triggers = std::move(nextTriggers);
193 return triggers;
194 }
195
196 void maybeAddSaveEventsTrigger(const ClientModel &old);
197
201
202 static Result update(ClientModel m, Action a);
203 };
204
205 // actions:
206 struct LoginAction {
207 std::string serverUrl;
208 std::string username;
209 std::string password;
210 std::optional<std::string> deviceName;
211 };
212
214 {
215 std::string serverUrl;
216 std::string username;
217 std::string token;
218 std::string deviceId;
219 };
220
225 {
226 std::string serverUrl;
227 std::string loginToken;
228 std::optional<std::string> deviceName;
229 };
230
231 struct LogoutAction {};
233
235 {
236 std::string userId;
237 };
238
240 {
241 std::string serverUrl;
242 };
243
244 struct SyncAction {};
245
247 {
249 };
250
252 {
253 std::string roomId;
255 std::string fromEventId;
256 std::optional<int> limit;
257 };
258
260 {
261 std::string roomId;
263 std::optional<std::string> txnId{std::nullopt};
264 };
265
267 {
268 std::string roomId;
270 };
271
280 {
282 std::string roomId;
286 std::optional<std::string> txnId{std::nullopt};
287 };
288
304
306 {
307 std::string roomId;
308 std::string eventId;
309 std::optional<std::string> reason;
310 };
311
313 {
317 std::optional<std::string> roomAliasName;
318 std::optional<std::string> name;
319 std::optional<std::string> topic;
320 immer::array<std::string> invite;
321 //immer::array<Invite3pid> invite3pid;
322 std::optional<std::string> roomVersion;
324 immer::array<Event> initialState;
325 std::optional<Preset> preset;
326 std::optional<bool> isDirect;
328 };
329
331 {
332 std::string roomId;
333 };
334
336 {
337 std::string roomId;
338 std::string type;
339 std::string stateKey;
340 };
341
343 {
344 std::string roomId;
345 std::string userId;
346 };
347
349 {
350 std::string roomId;
351 };
352
354 {
355 std::string roomIdOrAlias;
356 immer::array<std::string> serverName;
357 };
358
360 {
361 std::string roomId;
362 };
363
365 {
366 std::string roomId;
367 };
368
370 {
371 std::string roomId;
372 std::string userId;
373 std::optional<std::string> reason;
374 };
375
377 {
378 std::string roomId;
379 std::string userId;
380 std::optional<std::string> reason;
381 };
382
384 {
385 std::string roomId;
386 std::string userId;
387 };
388
394
396 {
397 std::string roomId;
398 bool typing;
399 std::optional<int> timeoutMs;
400 };
401
403 {
404 std::string roomId;
405 std::string eventId;
406 };
407
409 {
410 std::string roomId;
411 std::string eventId;
412 };
413
415 {
417 std::optional<std::string> filename;
418 std::optional<std::string> contentType;
419 std::string uploadId; // to be used by library users
420 };
421
423 {
424 std::string mxcUri;
425 std::optional<FileDesc> downloadTo;
426 };
427
429 {
430 std::string mxcUri;
431 int width;
433 std::optional<ThumbnailResizingMethod> method;
434 std::optional<bool> allowRemote;
435 std::optional<FileDesc> downloadTo;
436 };
437
439 {
441 };
442
447
449 {
450 };
451
456
458 {
460 immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
461 std::optional<std::string> txnId{std::nullopt};
462 };
463
470 {
472 immer::map<std::string, immer::map<std::string, Event>> userToDeviceToEventMap;
474 std::optional<std::string> txnId{std::nullopt};
475 };
476
478 {
479 };
480
489 {
492 static std::size_t randomSize(std::size_t numToGen);
494 std::size_t numToGen;
497 };
498
500 {
502 };
503
529 {
539 immer::map<
540 std::string /* userId */,
541 immer::flex_vector<std::string /* deviceId */>> userIdToDeviceIdsMap;
542 };
543
545 {
546 static std::size_t randomSize(immer::map<std::string, immer::flex_vector<std::string>> devicesToSend);
547 std::string roomId;
548 std::string sessionId;
549 std::string sessionKey;
550 immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
552 };
553
573 {
574 static std::size_t maxRandomSize();
575 static std::size_t minRandomSize();
576
578 std::string roomId;
587 };
588
595
605 {
607 immer::map<
608 std::string /* userId */,
609 immer::map<std::string /* deviceId */, DeviceTrustLevel>> trustLevelMap;
610 };
611
616
621 {
622 using UserIdToDeviceIdMap = immer::map<std::string, immer::flex_vector<std::string>>;
623 static std::size_t randomSize(UserIdToDeviceIdMap devices);
624
626 std::string roomId;
634 };
635
644 {
646 std::string fileContent;
648 std::string password;
649 };
650
655
657 {
658 std::string userId;
659 };
660
662 {
663 std::optional<std::string> avatarUrl;
664 };
665
667 {
668 std::optional<std::string> displayName;
669 };
670
673 {
676 immer::map<std::string, EventList> timelineEvents;
682 immer::map<std::string, EventList> relatedEvents;
683 };
684
688 {
690 immer::map<std::string, std::size_t> roomIdToMaxToKeepMap;
691 };
692
693 template<class Archive>
694 void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
695 {
696 bool dummySyncing{false};
697 ar
698 & m.serverUrl
699 & m.userId
700 & m.token
701 & m.deviceId
702 & m.loggedIn
703
704 & dummySyncing
705 & m.firstRetryMs
707 & m.maxRetryMs
708 & m.syncTimeoutMs
711 & m.syncToken
712
713 & m.roomList
714 & m.presence
715 & m.accountData
716
717 & m.nextTxnId
718
719 & m.toDevice;
720 // version <= 1 uses std::optional<Crypto>
721 // while version >= 2 uses std::optional<immer::box<Crypto>>
722 if (version >= 2) {
723 ar & m.crypto;
724 } else {
725 if constexpr (typename Archive::is_loading()) {
726 std::optional<Crypto> crypto;
727 ar >> crypto;
728 if (crypto.has_value()) {
729 m.crypto = immer::box<Crypto>(std::move(crypto).value());
730 }
731 }
732 // otherwise is_saving, which will always use the latest version
733 // this is unreachable
734 }
735
736 ar
738
739 & m.deviceLists
740 ;
741
742 if (version >= 1) { ar & m.trustLevelNeededToSendKeys; }
743 }
744}
745
746BOOST_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
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:694
Definition clientutil.hpp:140
Definition client-model.hpp:377
std::optional< std::string > reason
Definition client-model.hpp:380
std::string roomId
Definition client-model.hpp:378
std::string userId
Definition client-model.hpp:379
Definition client-model.hpp:545
std::string roomId
Definition client-model.hpp:547
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string > > devicesToSend)
Definition client-model.cpp:308
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:550
RandomData random
Definition client-model.hpp:551
std::string sessionId
Definition client-model.hpp:548
std::string sessionKey
Definition client-model.hpp:549
Definition client-model.hpp:148
constexpr auto make(Args &&...args) const
Definition client-model.hpp:150
std::string serverUrl
Definition client-model.hpp:163
std::string token
Definition client-model.hpp:164
Definition client-model.hpp:59
auto popAllTriggers()
Definition client-model.hpp:190
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:125
std::string userId
Definition client-model.hpp:61
void maybeAddSaveEventsTrigger(const ClientModel &old)
Definition client-model.cpp:435
int syncTimeoutMs
Definition client-model.hpp:71
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition client-model.cpp:430
immer::flex_vector< std::string > devicesToSendKeys(std::string userId) const
Definition client-model.cpp:242
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:198
std::optional< immer::box< Crypto > > crypto
Definition client-model.hpp:85
auto popAllJobs()
Definition client-model.hpp:176
immer::map< std::string, Event > presence
Definition client-model.hpp:77
std::size_t numOneTimeKeysNeeded() const
Definition client-model.cpp:266
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:186
std::string serverUrl
Definition client-model.hpp:60
auto roomIdsByTagId() const -> immer::map< std::string, immer::map< std::string, double > >
Definition client-model.cpp:410
immer::map< std::string, Event > accountData
Definition client-model.hpp:78
static Result update(ClientModel m, Action a)
Definition client-model.cpp:41
void addTrigger(KazvTrigger t)
Definition client-model.hpp:182
void addTriggers(immer::flex_vector< KazvTrigger > c)
Definition client-model.hpp:186
bool shouldSync
Definition client-model.hpp:67
std::string incrementalSyncFilterId
Definition client-model.hpp:73
ClientResult Result
Definition client-model.hpp:200
void addJob(BaseJob j)
Definition client-model.hpp:172
immer::flex_vector< BaseJob > nextJobs
Definition client-model.hpp:81
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition client-model.cpp:371
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:316
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:168
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:394
std::optional< std::string > syncToken
Definition client-model.hpp:74
std::string deviceId
Definition client-model.hpp:63
Definition client-model.hpp:313
std::optional< std::string > name
Definition client-model.hpp:318
JsonWrap creationContent
Definition client-model.hpp:323
immer::array< std::string > invite
Definition client-model.hpp:320
std::optional< Preset > preset
Definition client-model.hpp:325
std::optional< std::string > roomVersion
Definition client-model.hpp:322
std::optional< std::string > roomAliasName
Definition client-model.hpp:317
std::optional< bool > isDirect
Definition client-model.hpp:326
JsonWrap powerLevelContentOverride
Definition client-model.hpp:327
Visibility visibility
Definition client-model.hpp:316
immer::array< Event > initialState
Definition client-model.hpp:324
std::optional< std::string > topic
Definition client-model.hpp:319
Definition device-list-tracker.hpp:58
Definition client-model.hpp:423
std::string mxcUri
Definition client-model.hpp:424
std::optional< FileDesc > downloadTo
Definition client-model.hpp:425
Definition client-model.hpp:429
std::string mxcUri
Definition client-model.hpp:430
std::optional< FileDesc > downloadTo
Definition client-model.hpp:435
std::optional< ThumbnailResizingMethod > method
Definition client-model.hpp:433
std::optional< bool > allowRemote
Definition client-model.hpp:434
int width
Definition client-model.hpp:431
int height
Definition client-model.hpp:432
The action to encrypt an megolm event for a room.
Definition client-model.hpp:573
static std::size_t maxRandomSize()
Definition client-model.cpp:285
static std::size_t minRandomSize()
Definition client-model.cpp:290
Event e
The event to encrypt.
Definition client-model.hpp:580
RandomData random
Random data for the operation.
Definition client-model.hpp:586
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition client-model.hpp:582
std::string roomId
The id of the room to encrypt for.
Definition client-model.hpp:578
Ensure keys from devices of a user.
Definition client-model.hpp:529
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:541
Definition client-model.hpp:365
std::string roomId
Definition client-model.hpp:366
The action to generate one-time keys.
Definition client-model.hpp:489
static std::size_t randomSize(std::size_t numToGen)
Definition client-model.cpp:303
RandomData random
The random data used to generate keys.
Definition client-model.hpp:496
std::size_t numToGen
The number of keys to generate.
Definition client-model.hpp:494
Definition client-model.hpp:331
std::string roomId
Definition client-model.hpp:332
Definition client-model.hpp:336
std::string stateKey
Definition client-model.hpp:339
std::string type
Definition client-model.hpp:338
std::string roomId
Definition client-model.hpp:337
Definition client-model.hpp:657
std::string userId
Definition client-model.hpp:658
Definition client-model.hpp:240
std::string serverUrl
Definition client-model.hpp:241
Definition client-model.hpp:235
std::string userId
Definition client-model.hpp:236
Definition client-model.hpp:232
Import keys from key backup file.
Definition client-model.hpp:644
std::string fileContent
The content of the key backup file.
Definition client-model.hpp:646
std::string password
The password.
Definition client-model.hpp:648
Definition client-model.hpp:343
std::string userId
Definition client-model.hpp:345
std::string roomId
Definition client-model.hpp:344
Definition client-model.hpp:354
immer::array< std::string > serverName
Definition client-model.hpp:356
std::string roomIdOrAlias
Definition client-model.hpp:355
Definition client-model.hpp:349
std::string roomId
Definition client-model.hpp:350
Definition client-model.hpp:370
std::string roomId
Definition client-model.hpp:371
std::string userId
Definition client-model.hpp:372
std::optional< std::string > reason
Definition client-model.hpp:373
Definition client-model.hpp:360
std::string roomId
Definition client-model.hpp:361
Load events from the storage into the model.
Definition client-model.hpp:673
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:682
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:676
Status
Definition local-echo.hpp:21
Definition client-model.hpp:206
std::string password
Definition client-model.hpp:209
std::string serverUrl
Definition client-model.hpp:207
std::string username
Definition client-model.hpp:208
std::optional< std::string > deviceName
Definition client-model.hpp:210
Definition client-model.hpp:231
Login using the m.token.login flow.
Definition client-model.hpp:225
std::string loginToken
Definition client-model.hpp:227
std::string serverUrl
Definition client-model.hpp:226
std::optional< std::string > deviceName
Definition client-model.hpp:228
Notify that the verification tracker model has been changed.
Definition client-model.hpp:654
Definition client-model.hpp:252
std::string fromEventId
Must be where the Gap is.
Definition client-model.hpp:255
std::optional< int > limit
Definition client-model.hpp:256
std::string roomId
Definition client-model.hpp:253
Definition client-model.hpp:449
Definition client-model.hpp:403
std::string eventId
Definition client-model.hpp:405
std::string roomId
Definition client-model.hpp:404
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition client-model.hpp:621
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition client-model.hpp:622
Event e
The key event to encrypt.
Definition client-model.hpp:630
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition client-model.hpp:628
std::string roomId
The room to share the key event in.
Definition client-model.hpp:626
RandomData random
The random data for the encryption.
Definition client-model.hpp:633
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition client-model.cpp:295
Definition client-model.hpp:444
Response response
Definition client-model.hpp:445
Remove events from the model, keeping only the latest maxToKeep events.
Definition client-model.hpp:688
immer::map< std::string, std::size_t > roomIdToMaxToKeepMap
A map from roomId to maxToKeep.
Definition client-model.hpp:690
Definition client-model.hpp:500
bool isInitialSync
Definition client-model.hpp:501
Definition client-model.hpp:306
std::string eventId
Definition client-model.hpp:308
std::optional< std::string > reason
Definition client-model.hpp:309
std::string roomId
Definition client-model.hpp:307
Definition basejob.hpp:49
Definition client-model.hpp:439
BaseJob job
Definition client-model.hpp:440
Definition room-model.hpp:419
Saves an local echo.
Definition client-model.hpp:280
std::string roomId
The room id.
Definition client-model.hpp:282
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition client-model.hpp:286
Event event
The event to send.
Definition client-model.hpp:284
Definition client-model.hpp:260
std::optional< std::string > txnId
Definition client-model.hpp:263
std::string roomId
Definition client-model.hpp:261
Event event
Definition client-model.hpp:262
Send multiple to device messages.
Definition client-model.hpp:470
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition client-model.hpp:474
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:472
Definition client-model.hpp:267
Event event
Definition client-model.hpp:269
std::string roomId
Definition client-model.hpp:268
Definition client-model.hpp:458
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:460
std::optional< std::string > txnId
Definition client-model.hpp:461
Event event
Definition client-model.hpp:459
Definition client-model.hpp:453
Event accountDataEvent
Definition client-model.hpp:454
Definition client-model.hpp:390
std::string roomId
Definition client-model.hpp:391
Event accountDataEvent
Definition client-model.hpp:392
Definition client-model.hpp:662
std::optional< std::string > avatarUrl
Definition client-model.hpp:663
Definition client-model.hpp:590
std::string userId
Definition client-model.hpp:591
DeviceTrustLevel trustLevel
Definition client-model.hpp:593
std::string deviceId
Definition client-model.hpp:592
Set the trust levels of devices.
Definition client-model.hpp:605
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:609
Definition client-model.hpp:667
std::optional< std::string > displayName
Definition client-model.hpp:668
Definition client-model.hpp:409
std::string eventId
Definition client-model.hpp:411
std::string roomId
Definition client-model.hpp:410
Definition client-model.hpp:247
bool shouldSync
Definition client-model.hpp:248
Definition client-model.hpp:613
DeviceTrustLevel trustLevel
Definition client-model.hpp:614
Definition client-model.hpp:396
bool typing
Definition client-model.hpp:398
std::optional< int > timeoutMs
Definition client-model.hpp:399
std::string roomId
Definition client-model.hpp:397
Definition client-model.hpp:244
Definition client-model.hpp:214
std::string username
Definition client-model.hpp:216
std::string serverUrl
Definition client-model.hpp:215
std::string deviceId
Definition client-model.hpp:218
std::string token
Definition client-model.hpp:217
Definition client-model.hpp:384
std::string roomId
Definition client-model.hpp:385
std::string userId
Definition client-model.hpp:386
Updates the status of an local echo.
Definition client-model.hpp:296
std::string roomId
The room id.
Definition client-model.hpp:298
LocalEchoDesc::Status status
The updated status of this local echo.
Definition client-model.hpp:302
std::string txnId
The chosen txnId for this event.
Definition client-model.hpp:300
Definition client-model.hpp:415
std::string uploadId
Definition client-model.hpp:419
std::optional< std::string > contentType
Definition client-model.hpp:418
std::optional< std::string > filename
Definition client-model.hpp:417
FileDesc content
Definition client-model.hpp:416
Definition client-model.hpp:478