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
95 // Get the devices from which we are supposed to request keys.
96 // By the matrix specification, this is all verified devices of this user.
97 immer::map<std::string /* userId */, immer::flex_vector<std::string>> devicesToRequestKeys() const;
98
101 void maybeRotateSessions(ClientModel oldClient);
102
103 std::pair<Event, std::optional<std::string> /* sessionKey */>
104 megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random);
105
108 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);
109
112
118 json convertSignature(std::string signature) const;
119
121 std::size_t numOneTimeKeysNeeded() const;
122
124 auto directRoomMap() const -> immer::map<std::string, std::string>;
125
126 auto roomIdsUnderTag(std::string tagId) const -> immer::map<std::string, double>;
127
128 auto roomIdsByTagId() const -> immer::map<std::string, immer::map<std::string, double>>;
129
133 const Crypto &constCrypto() const;
134
138 template<class Func>
139 auto withCrypto(Func &&func) -> std::decay_t<std::invoke_result_t<Func &&, Crypto &>>
140 {
141 using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
142 if constexpr (std::is_same_v<ResT, void>) {
143 crypto = std::move(crypto).value()
144 .update([f=std::forward<Func>(func)](Crypto c) mutable {
145 std::forward<Func>(f)(c);
146 return c;
147 });
148 } else {
149 std::optional<ResT> res;
150 crypto = std::move(crypto).value()
151 .update([f=std::forward<Func>(func), &res](Crypto c) mutable {
152 res = std::forward<Func>(f)(c);
153 return c;
154 });
155 return std::move(res).value();
156 }
157 }
158
159 // helpers
160 template<class Job>
161 struct MakeJobT
162 {
163 template<class ...Args>
164 constexpr auto make(Args &&...args) const {
165 if constexpr (Job::needsAuth()) {
166 return Job(
167 serverUrl,
168 token,
169 std::forward<Args>(args)...);
170 } else {
171 return Job(
172 serverUrl,
173 std::forward<Args>(args)...);
174 }
175 }
176
177 std::string serverUrl;
178 std::string token;
179 };
180
181 template<class Job>
182 constexpr auto job() const {
184 }
185
186 inline void addJob(BaseJob j) {
187 nextJobs = std::move(nextJobs).push_back(std::move(j));
188 }
189
190 inline auto popAllJobs() {
191 auto jobs = std::move(nextJobs);
193 return jobs;
194 };
195
196 inline void addTrigger(KazvTrigger t) {
197 addTriggers({t});
198 }
199
200 inline void addTriggers(immer::flex_vector<KazvTrigger> c) {
201 nextTriggers = std::move(nextTriggers) + c;
202 }
203
204 inline auto popAllTriggers() {
205 auto triggers = std::move(nextTriggers);
207 return triggers;
208 }
209
210 void maybeAddSaveEventsTrigger(const ClientModel &old);
211
215
216 static Result update(ClientModel m, Action a);
217 };
218
219 // actions:
220 struct LoginAction {
221 std::string serverUrl;
222 std::string username;
223 std::string password;
224 std::optional<std::string> deviceName;
225 };
226
228 {
229 std::string serverUrl;
230 std::string username;
231 std::string token;
232 std::string deviceId;
233 };
234
239 {
240 std::string serverUrl;
241 std::string loginToken;
242 std::optional<std::string> deviceName;
243 };
244
245 struct LogoutAction {};
247
249 {
250 std::string userId;
251 };
252
254 {
255 std::string serverUrl;
256 };
257
258 struct SyncAction {};
259
261 {
263 };
264
266 {
267 std::string roomId;
269 std::string fromEventId;
270 std::optional<int> limit;
271 };
272
274 {
275 std::string roomId;
277 std::optional<std::string> txnId{std::nullopt};
278 };
279
281 {
282 std::string roomId;
284 };
285
294 {
296 std::string roomId;
300 std::optional<std::string> txnId{std::nullopt};
301 };
302
318
320 {
321 std::string roomId;
322 std::string eventId;
323 std::optional<std::string> reason;
324 };
325
327 {
331 std::optional<std::string> roomAliasName;
332 std::optional<std::string> name;
333 std::optional<std::string> topic;
334 immer::array<std::string> invite;
335 //immer::array<Invite3pid> invite3pid;
336 std::optional<std::string> roomVersion;
338 immer::array<Event> initialState;
339 std::optional<Preset> preset;
340 std::optional<bool> isDirect;
342 };
343
345 {
346 std::string roomId;
347 };
348
350 {
351 std::string roomId;
352 std::string type;
353 std::string stateKey;
354 };
355
357 {
358 std::string roomId;
359 std::string userId;
360 };
361
363 {
364 std::string roomId;
365 };
366
368 {
369 std::string roomIdOrAlias;
370 immer::array<std::string> serverName;
371 };
372
374 {
375 std::string roomId;
376 };
377
379 {
380 std::string roomId;
381 };
382
384 {
385 std::string roomId;
386 std::string userId;
387 std::optional<std::string> reason;
388 };
389
391 {
392 std::string roomId;
393 std::string userId;
394 std::optional<std::string> reason;
395 };
396
398 {
399 std::string roomId;
400 std::string userId;
401 };
402
408
410 {
411 std::string roomId;
412 bool typing;
413 std::optional<int> timeoutMs;
414 };
415
417 {
418 std::string roomId;
419 std::string eventId;
420 };
421
423 {
424 std::string roomId;
425 std::string eventId;
426 };
427
429 {
431 std::optional<std::string> filename;
432 std::optional<std::string> contentType;
433 std::string uploadId; // to be used by library users
434 };
435
437 {
438 std::string mxcUri;
439 std::optional<FileDesc> downloadTo;
440 };
441
443 {
444 std::string mxcUri;
445 int width;
447 std::optional<ThumbnailResizingMethod> method;
448 std::optional<bool> allowRemote;
449 std::optional<FileDesc> downloadTo;
450 };
451
453 {
455 };
456
461
463 {
464 };
465
470
472 {
474 immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
475 std::optional<std::string> txnId{std::nullopt};
476 };
477
484 {
486 immer::map<std::string, immer::map<std::string, Event>> userToDeviceToEventMap;
488 std::optional<std::string> txnId{std::nullopt};
489 };
490
492 {
493 };
494
503 {
506 static std::size_t randomSize(std::size_t numToGen);
508 std::size_t numToGen;
511 };
512
514 {
516 };
517
543 {
553 immer::map<
554 std::string /* userId */,
555 immer::flex_vector<std::string /* deviceId */>> userIdToDeviceIdsMap;
556 };
557
559 {
560 static std::size_t randomSize(immer::map<std::string, immer::flex_vector<std::string>> devicesToSend);
561 std::string roomId;
562 std::string sessionId;
563 std::string sessionKey;
564 immer::map<std::string, immer::flex_vector<std::string>> devicesToSend;
566 };
567
587 {
588 static std::size_t maxRandomSize();
589 static std::size_t minRandomSize();
590
592 std::string roomId;
601 };
602
609
619 {
621 immer::map<
622 std::string /* userId */,
623 immer::map<std::string /* deviceId */, DeviceTrustLevel>> trustLevelMap;
624 };
625
630
635 {
636 using UserIdToDeviceIdMap = immer::map<std::string, immer::flex_vector<std::string>>;
637 static std::size_t randomSize(UserIdToDeviceIdMap devices);
638
640 std::string roomId;
648 };
649
658 {
660 std::string fileContent;
662 std::string password;
663 };
664
669
671 {
672 std::string roomId;
674 immer::map<std::string, immer::flex_vector<std::string>> devices;
675 };
676
678 {
679 std::string userId;
680 };
681
683 {
684 std::optional<std::string> avatarUrl;
685 };
686
688 {
689 std::optional<std::string> displayName;
690 };
691
694 {
697 immer::map<std::string, EventList> timelineEvents;
703 immer::map<std::string, EventList> relatedEvents;
704 };
705
709 {
711 immer::map<std::string, std::size_t> roomIdToMaxToKeepMap;
712 };
713
714 template<class Archive>
715 void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
716 {
717 bool dummySyncing{false};
718 ar
719 & m.serverUrl
720 & m.userId
721 & m.token
722 & m.deviceId
723 & m.loggedIn
724
725 & dummySyncing
726 & m.firstRetryMs
728 & m.maxRetryMs
729 & m.syncTimeoutMs
732 & m.syncToken
733
734 & m.roomList
735 & m.presence
736 & m.accountData
737
738 & m.nextTxnId
739
740 & m.toDevice;
741 // version <= 1 uses std::optional<Crypto>
742 // while version >= 2 uses std::optional<immer::box<Crypto>>
743 if (version >= 2) {
744 ar & m.crypto;
745 } else {
746 if constexpr (typename Archive::is_loading()) {
747 std::optional<Crypto> crypto;
748 ar >> crypto;
749 if (crypto.has_value()) {
750 m.crypto = immer::box<Crypto>(std::move(crypto).value());
751 }
752 }
753 // otherwise is_saving, which will always use the latest version
754 // this is unreachable
755 }
756
757 ar
759
760 & m.deviceLists
761 ;
762
763 if (version >= 1) { ar & m.trustLevelNeededToSendKeys; }
764 }
765}
766
767BOOST_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:164
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::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, RequestShareRoomSessionKeyAction, GetUserProfileAction, SetAvatarUrlAction, SetDisplayNameAction, ResubmitJobAction, LoadEventsFromStorageAction, PurgeRoomTimelineAction > ClientAction
Definition clientfwd.hpp:162
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:166
immer::flex_vector< Event > EventList
Definition types.hpp:107
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition client-model.hpp:715
Definition clientutil.hpp:140
Device identity keys.
Definition device_keys.hpp:13
Definition client-model.hpp:391
std::optional< std::string > reason
Definition client-model.hpp:394
std::string roomId
Definition client-model.hpp:392
std::string userId
Definition client-model.hpp:393
Definition client-model.hpp:559
std::string roomId
Definition client-model.hpp:561
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string > > devicesToSend)
Definition client-model.cpp:371
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:564
RandomData random
Definition client-model.hpp:565
std::string sessionId
Definition client-model.hpp:562
std::string sessionKey
Definition client-model.hpp:563
Definition client-model.hpp:162
constexpr auto make(Args &&...args) const
Definition client-model.hpp:164
std::string serverUrl
Definition client-model.hpp:177
std::string token
Definition client-model.hpp:178
Definition client-model.hpp:59
auto popAllTriggers()
Definition client-model.hpp:204
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:139
std::string userId
Definition client-model.hpp:61
void maybeAddSaveEventsTrigger(const ClientModel &old)
Definition client-model.cpp:498
int syncTimeoutMs
Definition client-model.hpp:71
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition client-model.cpp:493
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:212
std::optional< immer::box< Crypto > > crypto
Definition client-model.hpp:85
auto popAllJobs()
Definition client-model.hpp:190
immer::map< std::string, Event > presence
Definition client-model.hpp:77
std::size_t numOneTimeKeysNeeded() const
Definition client-model.cpp:329
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:473
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:196
void addTriggers(immer::flex_vector< KazvTrigger > c)
Definition client-model.hpp:200
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:214
void addJob(BaseJob j)
Definition client-model.hpp:186
immer::flex_vector< BaseJob > nextJobs
Definition client-model.hpp:81
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition client-model.cpp:434
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:379
std::string initialSyncFilterId
Definition client-model.hpp:72
bool syncing
Definition client-model.hpp:66
immer::map< std::string, immer::flex_vector< std::string > > devicesToRequestKeys() const
Definition client-model.cpp:311
std::string token
Definition client-model.hpp:62
std::string nextTxnId
Definition client-model.hpp:80
constexpr auto job() const
Definition client-model.hpp:182
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:457
std::optional< std::string > syncToken
Definition client-model.hpp:74
std::string deviceId
Definition client-model.hpp:63
Definition client-model.hpp:327
std::optional< std::string > name
Definition client-model.hpp:332
JsonWrap creationContent
Definition client-model.hpp:337
immer::array< std::string > invite
Definition client-model.hpp:334
std::optional< Preset > preset
Definition client-model.hpp:339
std::optional< std::string > roomVersion
Definition client-model.hpp:336
std::optional< std::string > roomAliasName
Definition client-model.hpp:331
std::optional< bool > isDirect
Definition client-model.hpp:340
JsonWrap powerLevelContentOverride
Definition client-model.hpp:341
Visibility visibility
Definition client-model.hpp:330
immer::array< Event > initialState
Definition client-model.hpp:338
std::optional< std::string > topic
Definition client-model.hpp:333
Definition device-list-tracker.hpp:68
Definition client-model.hpp:437
std::string mxcUri
Definition client-model.hpp:438
std::optional< FileDesc > downloadTo
Definition client-model.hpp:439
Definition client-model.hpp:443
std::string mxcUri
Definition client-model.hpp:444
std::optional< FileDesc > downloadTo
Definition client-model.hpp:449
std::optional< ThumbnailResizingMethod > method
Definition client-model.hpp:447
std::optional< bool > allowRemote
Definition client-model.hpp:448
int width
Definition client-model.hpp:445
int height
Definition client-model.hpp:446
The action to encrypt an megolm event for a room.
Definition client-model.hpp:587
static std::size_t maxRandomSize()
Definition client-model.cpp:348
static std::size_t minRandomSize()
Definition client-model.cpp:353
Event e
The event to encrypt.
Definition client-model.hpp:594
RandomData random
Random data for the operation.
Definition client-model.hpp:600
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition client-model.hpp:596
std::string roomId
The id of the room to encrypt for.
Definition client-model.hpp:592
Ensure keys from devices of a user.
Definition client-model.hpp:543
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:555
Definition client-model.hpp:379
std::string roomId
Definition client-model.hpp:380
The action to generate one-time keys.
Definition client-model.hpp:503
static std::size_t randomSize(std::size_t numToGen)
Definition client-model.cpp:366
RandomData random
The random data used to generate keys.
Definition client-model.hpp:510
std::size_t numToGen
The number of keys to generate.
Definition client-model.hpp:508
Definition client-model.hpp:345
std::string roomId
Definition client-model.hpp:346
Definition client-model.hpp:350
std::string stateKey
Definition client-model.hpp:353
std::string type
Definition client-model.hpp:352
std::string roomId
Definition client-model.hpp:351
Definition client-model.hpp:678
std::string userId
Definition client-model.hpp:679
Definition client-model.hpp:254
std::string serverUrl
Definition client-model.hpp:255
Definition client-model.hpp:249
std::string userId
Definition client-model.hpp:250
Definition client-model.hpp:246
Import keys from key backup file.
Definition client-model.hpp:658
std::string fileContent
The content of the key backup file.
Definition client-model.hpp:660
std::string password
The password.
Definition client-model.hpp:662
Definition client-model.hpp:357
std::string userId
Definition client-model.hpp:359
std::string roomId
Definition client-model.hpp:358
Definition client-model.hpp:368
immer::array< std::string > serverName
Definition client-model.hpp:370
std::string roomIdOrAlias
Definition client-model.hpp:369
Definition client-model.hpp:363
std::string roomId
Definition client-model.hpp:364
Definition client-model.hpp:384
std::string roomId
Definition client-model.hpp:385
std::string userId
Definition client-model.hpp:386
std::optional< std::string > reason
Definition client-model.hpp:387
Definition client-model.hpp:374
std::string roomId
Definition client-model.hpp:375
Load events from the storage into the model.
Definition client-model.hpp:694
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:703
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:697
Status
Definition local-echo.hpp:21
Definition client-model.hpp:220
std::string password
Definition client-model.hpp:223
std::string serverUrl
Definition client-model.hpp:221
std::string username
Definition client-model.hpp:222
std::optional< std::string > deviceName
Definition client-model.hpp:224
Definition client-model.hpp:245
Login using the m.token.login flow.
Definition client-model.hpp:239
std::string loginToken
Definition client-model.hpp:241
std::string serverUrl
Definition client-model.hpp:240
std::optional< std::string > deviceName
Definition client-model.hpp:242
Notify that the verification tracker model has been changed.
Definition client-model.hpp:668
Definition client-model.hpp:266
std::string fromEventId
Must be where the Gap is.
Definition client-model.hpp:269
std::optional< int > limit
Definition client-model.hpp:270
std::string roomId
Definition client-model.hpp:267
Definition client-model.hpp:463
Definition client-model.hpp:417
std::string eventId
Definition client-model.hpp:419
std::string roomId
Definition client-model.hpp:418
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition client-model.hpp:635
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition client-model.hpp:636
Event e
The key event to encrypt.
Definition client-model.hpp:644
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition client-model.hpp:642
std::string roomId
The room to share the key event in.
Definition client-model.hpp:640
RandomData random
The random data for the encryption.
Definition client-model.hpp:647
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition client-model.cpp:358
Definition client-model.hpp:458
Response response
Definition client-model.hpp:459
Remove events from the model, keeping only the latest maxToKeep events.
Definition client-model.hpp:709
immer::map< std::string, std::size_t > roomIdToMaxToKeepMap
A map from roomId to maxToKeep.
Definition client-model.hpp:711
Definition client-model.hpp:514
bool isInitialSync
Definition client-model.hpp:515
Definition client-model.hpp:320
std::string eventId
Definition client-model.hpp:322
std::optional< std::string > reason
Definition client-model.hpp:323
std::string roomId
Definition client-model.hpp:321
Definition client-model.hpp:671
immer::map< std::string, immer::flex_vector< std::string > > devices
Definition client-model.hpp:674
Event event
Definition client-model.hpp:673
std::string roomId
Definition client-model.hpp:672
Definition basejob.hpp:49
Definition client-model.hpp:453
BaseJob job
Definition client-model.hpp:454
Definition room-model.hpp:450
Saves an local echo.
Definition client-model.hpp:294
std::string roomId
The room id.
Definition client-model.hpp:296
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition client-model.hpp:300
Event event
The event to send.
Definition client-model.hpp:298
Definition client-model.hpp:274
std::optional< std::string > txnId
Definition client-model.hpp:277
std::string roomId
Definition client-model.hpp:275
Event event
Definition client-model.hpp:276
Send multiple to device messages.
Definition client-model.hpp:484
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition client-model.hpp:488
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:486
Definition client-model.hpp:281
Event event
Definition client-model.hpp:283
std::string roomId
Definition client-model.hpp:282
Definition client-model.hpp:472
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition client-model.hpp:474
std::optional< std::string > txnId
Definition client-model.hpp:475
Event event
Definition client-model.hpp:473
Definition client-model.hpp:467
Event accountDataEvent
Definition client-model.hpp:468
Definition client-model.hpp:404
std::string roomId
Definition client-model.hpp:405
Event accountDataEvent
Definition client-model.hpp:406
Definition client-model.hpp:683
std::optional< std::string > avatarUrl
Definition client-model.hpp:684
Definition client-model.hpp:604
std::string userId
Definition client-model.hpp:605
DeviceTrustLevel trustLevel
Definition client-model.hpp:607
std::string deviceId
Definition client-model.hpp:606
Set the trust levels of devices.
Definition client-model.hpp:619
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:623
Definition client-model.hpp:688
std::optional< std::string > displayName
Definition client-model.hpp:689
Definition client-model.hpp:423
std::string eventId
Definition client-model.hpp:425
std::string roomId
Definition client-model.hpp:424
Definition client-model.hpp:261
bool shouldSync
Definition client-model.hpp:262
Definition client-model.hpp:627
DeviceTrustLevel trustLevel
Definition client-model.hpp:628
Definition client-model.hpp:410
bool typing
Definition client-model.hpp:412
std::optional< int > timeoutMs
Definition client-model.hpp:413
std::string roomId
Definition client-model.hpp:411
Definition client-model.hpp:258
Definition client-model.hpp:228
std::string username
Definition client-model.hpp:230
std::string serverUrl
Definition client-model.hpp:229
std::string deviceId
Definition client-model.hpp:232
std::string token
Definition client-model.hpp:231
Definition client-model.hpp:398
std::string roomId
Definition client-model.hpp:399
std::string userId
Definition client-model.hpp:400
Updates the status of an local echo.
Definition client-model.hpp:310
std::string roomId
The room id.
Definition client-model.hpp:312
LocalEchoDesc::Status status
The updated status of this local echo.
Definition client-model.hpp:316
std::string txnId
The chosen txnId for this event.
Definition client-model.hpp:314
Definition client-model.hpp:429
std::string uploadId
Definition client-model.hpp:433
std::optional< std::string > contentType
Definition client-model.hpp:432
std::optional< std::string > filename
Definition client-model.hpp:431
FileDesc content
Definition client-model.hpp:430
Definition client-model.hpp:492