Go to the documentation of this file.
16 #include <lager/context.hpp>
17 #include <boost/hana.hpp>
85 std::optional<immer::box<Crypto>>
crypto;
97 std::pair<Event, std::optional<std::string> >
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);
125 using ResT = std::decay_t<std::invoke_result_t<Func &&, Crypto &>>;
126 if constexpr (std::is_same_v<ResT, void>) {
128 .update([f=std::forward<Func>(func)](
Crypto c)
mutable {
129 std::forward<Func>(f)(c);
133 std::optional<ResT> res;
135 .update([f=std::forward<Func>(func), &res](
Crypto c)
mutable {
136 res = std::forward<Func>(f)(c);
139 return std::move(res).value();
147 template<
class ...Args>
148 constexpr
auto make(Args &&...args)
const {
149 if constexpr (Job::needsAuth()) {
153 std::forward<Args>(args)...);
157 std::forward<Args>(args)...);
166 constexpr
auto job()
const {
249 std::optional<std::string>
txnId{std::nullopt};
272 std::optional<std::string>
txnId{std::nullopt};
304 std::optional<std::string>
name;
419 std::optional<ThumbnailResizingMethod>
method;
447 std::optional<std::string>
txnId{std::nullopt};
460 std::optional<std::string>
txnId{std::nullopt};
581 template<
class Archive>
584 bool dummySyncing{
false};
613 if constexpr (
typename Archive::is_loading()) {
614 std::optional<Crypto> crypto;
616 if (crypto.has_value()) {
617 m.
crypto = immer::box<Crypto>(std::move(crypto).value());
std::string roomId
Definition: client-model.hpp:323
std::string roomId
Definition: client-model.hpp:352
Definition: client-model.hpp:381
std::string roomIdOrAlias
Definition: client-model.hpp:341
std::string incrementalSyncFilterId
Definition: client-model.hpp:73
Definition: client-model.hpp:576
int height
Definition: client-model.hpp:418
std::string roomId
The room id.
Definition: client-model.hpp:284
std::string sessionId
Definition: client-model.hpp:494
std::string roomId
Definition: client-model.hpp:493
std::optional< std::string > roomVersion
Definition: client-model.hpp:308
std::optional< std::string > displayName
Definition: client-model.hpp:578
constexpr auto job() const
Definition: client-model.hpp:166
std::string roomId
Definition: client-model.hpp:377
Updates the status of an local echo.
Definition: client-model.hpp:281
std::string RandomData
Definition: crypto-util.hpp:34
Definition: client-model.hpp:218
The action to generate one-time keys.
Definition: client-model.hpp:474
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string >> devicesToSend)
Definition: client-model.cpp:296
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition: client-model.cpp:359
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition: client-model.hpp:558
std::string roomId
Definition: client-model.hpp:371
Event e
The event to encrypt.
Definition: client-model.hpp:526
DeviceTrustLevel trustLevelNeededToSendKeys
Definition: client-model.hpp:89
std::string password
Definition: client-model.hpp:205
std::string roomId
Definition: client-model.hpp:390
std::string userId
Definition: client-model.hpp:61
std::optional< std::string > txnId
Definition: client-model.hpp:447
std::string serverUrl
Definition: client-model.hpp:227
@ Scale
Definition: client-model.hpp:55
std::string userId
Definition: client-model.hpp:358
std::string txnId
The chosen txnId for this event.
Definition: client-model.hpp:286
std::string username
Definition: client-model.hpp:212
std::string stateKey
Definition: client-model.hpp:325
Definition: client-model.hpp:145
immer::map< std::string, Event > accountData
Definition: client-model.hpp:78
std::string deviceId
Definition: client-model.hpp:538
Definition: client-model.hpp:438
std::optional< std::string > name
Definition: client-model.hpp:304
Definition: client-model.hpp:230
bool loggedIn
Definition: client-model.hpp:64
immer::array< std::string > invite
Definition: client-model.hpp:306
std::string userId
Definition: client-model.hpp:372
Definition: client-model.hpp:463
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
auto roomIdsByTagId() const -> immer::map< std::string, immer::map< std::string, double >>
Definition: client-model.cpp:398
std::string roomId
Definition: client-model.hpp:330
std::string roomId
Definition: client-model.hpp:293
DeviceTrustLevel trustLevel
Definition: client-model.hpp:544
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
std::string roomId
Definition: client-model.hpp:318
std::optional< std::string > reason
Definition: client-model.hpp:366
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition: client-model.hpp:446
int firstRetryMs
Definition: client-model.hpp:68
std::string eventId
Definition: client-model.hpp:397
std::optional< bool > allowRemote
Definition: client-model.hpp:420
RandomData random
Definition: client-model.hpp:497
Definition: client-model.hpp:490
Definition: client-model.hpp:339
Definition: client-model.hpp:485
bool shouldSync
Definition: client-model.hpp:67
int maxRetryMs
Definition: client-model.hpp:70
Event event
Definition: client-model.hpp:248
Definition: client-model.hpp:291
@ Crop
Definition: client-model.hpp:54
void addTriggers(immer::flex_vector< KazvEvent > c)
Definition: client-model.hpp:184
@ Private
Definition: client-model.hpp:41
std::optional< std::string > roomAliasName
Definition: client-model.hpp:303
std::string serverUrl
Definition: client-model.hpp:203
std::optional< std::string > syncToken
Definition: client-model.hpp:74
Definition: client-model.hpp:443
Definition: client-model.hpp:414
std::string deviceId
Definition: client-model.hpp:63
std::string roomId
Definition: client-model.hpp:383
JsonWrap creationContent
Definition: client-model.hpp:309
std::optional< immer::box< Crypto > > crypto
Definition: client-model.hpp:85
Definition: client-model.hpp:345
JsonWrap powerLevelContentOverride
Definition: client-model.hpp:313
static Result update(ClientModel m, Action a)
Definition: client-model.cpp:40
Definition: location.hpp:10
std::int_fast64_t Timestamp
Definition: event.hpp:18
void maybeRotateSessions(ClientModel oldClient)
rotate sessions for a room if there is a user in the room with devicesToSendKeys changes
Definition: client-model.cpp:304
FileDesc content
Definition: client-model.hpp:402
Saves an local echo.
Definition: client-model.hpp:265
std::string roomId
Definition: client-model.hpp:336
Definition: client-model.hpp:542
RandomData random
Random data for the operation.
Definition: client-model.hpp:532
Definition: client-model.hpp:434
std::optional< std::string > topic
Definition: client-model.hpp:305
static std::size_t maxRandomSize()
Definition: client-model.cpp:273
Definition: client-model.hpp:252
immer::flex_vector< BaseJob > nextJobs
Definition: client-model.hpp:81
ClientResult Result
Definition: client-model.hpp:196
@ Public
Definition: client-model.hpp:42
The action to encrypt an megolm event for a room.
Definition: client-model.hpp:518
const std::string DEFTXNID
Definition: client-model.hpp:37
@ PublicChat
Definition: client-model.hpp:48
int syncTimeoutMs
Definition: client-model.hpp:71
Definition: client-model.hpp:375
std::optional< std::string > deviceName
Definition: client-model.hpp:206
Definition: client-model.hpp:328
ClientAction Action
Definition: client-model.hpp:194
Definition: client-model.hpp:571
Response response
Definition: client-model.hpp:431
std::string userId
Definition: client-model.hpp:222
RoomVisibility
Definition: client-model.hpp:39
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
Event e
The key event to encrypt.
Definition: client-model.hpp:560
constexpr auto make(Args &&...args) const
Definition: client-model.hpp:148
std::string serverUrl
Definition: client-model.hpp:60
std::string roomId
Definition: client-model.hpp:239
std::optional< Preset > preset
Definition: client-model.hpp:311
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition: client-model.cpp:418
bool isInitialSync
Definition: client-model.hpp:487
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition: client-model.hpp:552
std::string type
Definition: client-model.hpp:324
Definition: client-model.hpp:388
auto popAllJobs()
Definition: client-model.hpp:174
std::optional< std::string > avatarUrl
Definition: client-model.hpp:573
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition: client-model.hpp:582
std::optional< FileDesc > downloadTo
Definition: client-model.hpp:421
immer::flex_vector< std::string > devicesToSendKeys(std::string userId) const
Definition: client-model.cpp:233
CreateRoomPreset
Definition: client-model.hpp:45
constexpr detail::DefaultValT DEFVAL
Definition: types.hpp:125
@ Unseen
Definition: device-list-tracker.hpp:29
std::size_t numOneTimeKeysNeeded() const
Definition: client-model.cpp:257
ThumbnailResizingMethod
Definition: client-model.hpp:52
std::string roomId
The room to share the key event in.
Definition: client-model.hpp:556
bool syncing
Definition: client-model.hpp:66
LocalEchoDesc::Status status
The updated status of this local echo.
Definition: client-model.hpp:288
std::string username
Definition: client-model.hpp:204
immer::flex_vector< KazvEvent > nextTriggers
Definition: client-model.hpp:82
std::string eventId
Definition: client-model.hpp:391
EventList toDevice
Definition: client-model.hpp:84
std::string mxcUri
Definition: client-model.hpp:410
auto popAllTriggers()
Definition: client-model.hpp:188
Definition: client-model.hpp:316
std::optional< std::string > reason
Definition: client-model.hpp:295
Event event
Definition: client-model.hpp:255
std::string mxcUri
Definition: client-model.hpp:416
std::string roomId
Definition: client-model.hpp:357
Event accountDataEvent
Definition: client-model.hpp:378
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition: client-model.hpp:528
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition: client-model.hpp:550
std::string token
Definition: client-model.hpp:62
std::string token
Definition: client-model.hpp:162
Definition: device-list-tracker.hpp:58
std::string serverUrl
Definition: client-model.hpp:211
Event event
Definition: client-model.hpp:445
Definition: client-model.hpp:225
Definition: client-model.hpp:202
std::pair< ClientModel, ClientEffect > ClientResult
Definition: clientfwd.hpp:149
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition: client-model.hpp:460
Definition: client-model.hpp:334
void addTrigger(KazvEvent t)
Definition: client-model.hpp:180
Definition: client-model.hpp:394
immer::array< std::string > serverName
Definition: client-model.hpp:342
Definition: client-model.hpp:220
std::optional< std::string > txnId
Definition: client-model.hpp:249
Definition: crypto.hpp:35
int retryTimeFactor
Definition: client-model.hpp:69
std::string userId
Definition: client-model.hpp:537
Definition: jsonwrap.hpp:22
Definition: client-model.hpp:245
std::string roomId
The room id.
Definition: client-model.hpp:268
std::string deviceId
Definition: client-model.hpp:214
Definition: client-model.hpp:298
Effect< ClientAction, lager::deps<> > ClientEffect
Definition: clientfwd.hpp:147
std::string roomId
Definition: client-model.hpp:364
BaseJob job
Definition: client-model.hpp:426
Definition: client-model.hpp:424
immer::map< std::string, Event > presence
Definition: client-model.hpp:77
std::string uploadId
Definition: client-model.hpp:405
std::string sessionKey
Definition: client-model.hpp:495
Send multiple to device messages.
Definition: client-model.hpp:455
std::string roomId
Definition: client-model.hpp:347
static std::size_t randomSize(std::size_t numToGen)
Definition: client-model.cpp:291
std::string fromEventId
Must be where the Gap is.
Definition: client-model.hpp:241
Status
Definition: local-echo.hpp:20
Definition: basejob.hpp:76
Definition: client-model.hpp:355
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
std::string roomId
The id of the room to encrypt for.
Definition: client-model.hpp:524
Event event
The event to send.
Definition: client-model.hpp:270
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition: client-model.cpp:283
std::optional< std::string > contentType
Definition: client-model.hpp:404
Definition: clientutil.hpp:216
std::optional< bool > isDirect
Definition: client-model.hpp:312
bool shouldSync
Definition: client-model.hpp:234
RandomData random
The random data used to generate keys.
Definition: client-model.hpp:482
@ PrivateChat
Definition: client-model.hpp:47
RoomListModel roomList
Definition: client-model.hpp:76
Definition: client-model.hpp:362
Definition: context.hpp:204
std::string initialSyncFilterId
Definition: client-model.hpp:72
std::string roomId
Definition: client-model.hpp:396
std::optional< FileDesc > downloadTo
Definition: client-model.hpp:411
std::string nextTxnId
Definition: client-model.hpp:80
Definition: client-model.hpp:232
bool typing
Definition: client-model.hpp:384
static std::size_t minRandomSize()
Definition: client-model.cpp:278
@ TrustedPrivateChat
Definition: client-model.hpp:49
Definition: file-desc.hpp:224
std::string roomId
Definition: client-model.hpp:254
Definition: client-model.hpp:321
std::string userId
Definition: client-model.hpp:568
std::string userId
Definition: client-model.hpp:331
std::string roomId
Definition: client-model.hpp:247
std::pair< Event, std::optional< std::string > > megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random)
Definition: client-model.cpp:125
std::string userId
Definition: client-model.hpp:365
std::optional< std::string > reason
Definition: client-model.hpp:359
Visibility visibility
Definition: client-model.hpp:302
Event accountDataEvent
Definition: client-model.hpp:440
std::optional< std::string > filename
Definition: client-model.hpp:403
Definition: client-model.hpp:400
std::size_t numToGen
The number of keys to generate.
Definition: client-model.hpp:480
std::string serverUrl
Definition: client-model.hpp:161
int width
Definition: client-model.hpp:417
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition: client-model.hpp:496
RandomData random
The random data for the encryption.
Definition: client-model.hpp:563
std::string eventId
Definition: client-model.hpp:294
Definition: client-model.hpp:217
auto roomIdsUnderTag(std::string tagId) const -> immer::map< std::string, double >
Definition: client-model.cpp:382
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition: client-model.hpp:272
Definition: client-model.hpp:535
Definition: client-model.hpp:58
Definition: room-model.hpp:389
std::optional< ThumbnailResizingMethod > method
Definition: client-model.hpp:419
DeviceTrustLevel
Definition: device-list-tracker.hpp:26
std::string token
Definition: client-model.hpp:213
immer::flex_vector< Event > EventList
Definition: types.hpp:107
std::optional< int > limit
Definition: client-model.hpp:242
Definition: client-model.hpp:369
Definition: client-model.hpp:350
Definition: client-model.hpp:237
Definition: client-model.hpp:566
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
Definition: client-model.hpp:429
void addJob(BaseJob j)
Definition: client-model.hpp:170
Definition: client-model.hpp:209
Definition: basejob.hpp:50
std::optional< int > timeoutMs
Definition: client-model.hpp:385
DeviceTrustLevel trustLevel
Definition: client-model.hpp:539
immer::array< Event > initialState
Definition: client-model.hpp:310
bool identityKeysUploaded
Definition: client-model.hpp:86
Definition: client-model.hpp:408
DeviceListTracker deviceLists
Definition: client-model.hpp:88