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());
Definition: basejob.hpp:77
Definition: crypto.hpp:36
Definition: context.hpp:205
Definition: file-desc.hpp:225
Definition: jsonwrap.hpp:23
Definition: location.hpp:10
std::variant< RoomListAction, LoginAction, TokenLoginAction, LogoutAction, HardLogoutAction, GetWellknownAction, GetVersionsAction, SyncAction, SetShouldSyncAction, PostInitialFiltersAction, SetAccountDataAction, PaginateTimelineAction, SendMessageAction, SendStateEventAction, SaveLocalEchoAction, UpdateLocalEchoStatusAction, RedactEventAction, CreateRoomAction, GetRoomStatesAction, GetStateEventAction, InviteToRoomAction, JoinRoomByIdAction, JoinRoomAction, LeaveRoomAction, ForgetRoomAction, KickAction, BanAction, UnbanAction, SetAccountDataPerRoomAction, ProcessResponseAction, SetTypingAction, PostReceiptAction, SetReadMarkerAction, UploadContentAction, DownloadContentAction, DownloadThumbnailAction, SendToDeviceMessageAction, SendMultipleToDeviceMessagesAction, UploadIdentityKeysAction, GenerateAndUploadOneTimeKeysAction, QueryKeysAction, ClaimKeysAction, EncryptMegOlmEventAction, SetDeviceTrustLevelAction, SetTrustLevelNeededToSendKeysAction, PrepareForSharingRoomKeyAction, GetUserProfileAction, SetAvatarUrlAction, SetDisplayNameAction, ResubmitJobAction > ClientAction
Definition: clientfwd.hpp:145
CreateRoomPreset
Definition: client-model.hpp:46
@ TrustedPrivateChat
Definition: client-model.hpp:49
@ PublicChat
Definition: client-model.hpp:48
@ PrivateChat
Definition: client-model.hpp:47
RoomVisibility
Definition: client-model.hpp:40
@ Public
Definition: client-model.hpp:42
@ Private
Definition: client-model.hpp:41
Effect< ClientAction, lager::deps<> > ClientEffect
Definition: clientfwd.hpp:147
DeviceTrustLevel
Definition: device-list-tracker.hpp:27
@ Unseen
Definition: device-list-tracker.hpp:29
std::string RandomData
Definition: crypto-util.hpp:34
std::variant< std::monostate, ReceivingPresenceEvent, ReceivingAccountDataEvent, ReceivingRoomTimelineEvent, ReceivingRoomStateEvent, RoomMembershipChanged, ReceivingRoomAccountDataEvent, ReceivingToDeviceMessage, LoginSuccessful, LoginFailed, SyncSuccessful, SyncFailed, PostInitialFiltersSuccessful, PostInitialFiltersFailed, PaginateSuccessful, PaginateFailed, CreateRoomSuccessful, CreateRoomFailed, InviteUserSuccessful, InviteUserFailed, JoinRoomSuccessful, JoinRoomFailed, LeaveRoomSuccessful, LeaveRoomFailed, ForgetRoomSuccessful, ForgetRoomFailed, SendMessageSuccessful, SendMessageFailed, SendToDeviceMessageSuccessful, SendToDeviceMessageFailed, InvalidMessageFormat, GetRoomStatesSuccessful, GetRoomStatesFailed, GetStateEventSuccessful, GetStateEventFailed, SendStateEventSuccessful, SendStateEventFailed, SetTypingSuccessful, SetTypingFailed, PostReceiptSuccessful, PostReceiptFailed, SetReadMarkerSuccessful, SetReadMarkerFailed, UploadContentSuccessful, UploadContentFailed, DownloadContentSuccessful, DownloadContentFailed, DownloadThumbnailSuccessful, DownloadThumbnailFailed, UploadIdentityKeysSuccessful, UploadIdentityKeysFailed, UploadOneTimeKeysSuccessful, UploadOneTimeKeysFailed, ClaimKeysSuccessful, ClaimKeysFailed, UnrecognizedResponse, ShouldQueryKeys > KazvEvent
Definition: kazvevents.hpp:390
const std::string DEFTXNID
Definition: client-model.hpp:37
std::int_fast64_t Timestamp
Definition: event.hpp:18
ThumbnailResizingMethod
Definition: client-model.hpp:53
@ Crop
Definition: client-model.hpp:54
@ Scale
Definition: client-model.hpp:55
constexpr detail::DefaultValT DEFVAL
Definition: types.hpp:125
std::pair< ClientModel, ClientEffect > ClientResult
Definition: clientfwd.hpp:149
immer::flex_vector< Event > EventList
Definition: types.hpp:107
void serialize(Archive &ar, ClientModel &m, std::uint32_t const version)
Definition: client-model.hpp:582
Definition: clientutil.hpp:217
Definition: client-model.hpp:363
std::optional< std::string > reason
Definition: client-model.hpp:366
std::string roomId
Definition: client-model.hpp:364
std::string userId
Definition: client-model.hpp:365
Definition: client-model.hpp:491
std::string roomId
Definition: client-model.hpp:493
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition: client-model.hpp:496
RandomData random
Definition: client-model.hpp:497
static std::size_t randomSize(immer::map< std::string, immer::flex_vector< std::string >> devicesToSend)
Definition: client-model.cpp:299
std::string sessionId
Definition: client-model.hpp:494
std::string sessionKey
Definition: client-model.hpp:495
Definition: client-model.hpp:146
constexpr auto make(Args &&...args) const
Definition: client-model.hpp:148
std::string serverUrl
Definition: client-model.hpp:161
std::string token
Definition: client-model.hpp:162
Definition: client-model.hpp:59
auto popAllTriggers()
Definition: client-model.hpp:188
RoomListModel roomList
Definition: client-model.hpp:76
auto withCrypto(Func &&func) -> std::decay_t< std::invoke_result_t< Func &&, Crypto & >>
Do func with crypto, returning its return value.
Definition: client-model.hpp:123
std::string userId
Definition: client-model.hpp:61
int syncTimeoutMs
Definition: client-model.hpp:71
const Crypto & constCrypto() const
Get the const reference of crypto of this client.
Definition: client-model.cpp:421
immer::flex_vector< std::string > devicesToSendKeys(std::string userId) const
Definition: client-model.cpp:233
int firstRetryMs
Definition: client-model.hpp:68
DeviceListTracker deviceLists
Definition: client-model.hpp:88
bool identityKeysUploaded
Definition: client-model.hpp:86
int maxRetryMs
Definition: client-model.hpp:70
ClientAction Action
Definition: client-model.hpp:194
std::optional< immer::box< Crypto > > crypto
Definition: client-model.hpp:85
auto popAllJobs()
Definition: client-model.hpp:174
immer::map< std::string, Event > presence
Definition: client-model.hpp:77
std::size_t numOneTimeKeysNeeded() const
Definition: client-model.cpp:257
auto roomIdsByTagId() const -> immer::map< std::string, immer::map< std::string, double >>
Definition: client-model.cpp:401
std::string serverUrl
Definition: client-model.hpp:60
immer::map< std::string, Event > accountData
Definition: client-model.hpp:78
static Result update(ClientModel m, Action a)
Definition: client-model.cpp:40
bool shouldSync
Definition: client-model.hpp:67
void addTrigger(KazvEvent t)
Definition: client-model.hpp:180
std::string incrementalSyncFilterId
Definition: client-model.hpp:73
ClientResult Result
Definition: client-model.hpp:196
void addTriggers(immer::flex_vector< KazvEvent > c)
Definition: client-model.hpp:184
void addJob(BaseJob j)
Definition: client-model.hpp:170
immer::flex_vector< BaseJob > nextJobs
Definition: client-model.hpp:81
auto directRoomMap() const -> immer::map< std::string, std::string >
Definition: client-model.cpp:362
int retryTimeFactor
Definition: client-model.hpp:69
DeviceTrustLevel trustLevelNeededToSendKeys
Definition: client-model.hpp:89
void maybeRotateSessions(ClientModel oldClient)
rotate sessions for a room if there is a user in the room with devicesToSendKeys changes
Definition: client-model.cpp:307
std::string initialSyncFilterId
Definition: client-model.hpp:72
bool syncing
Definition: client-model.hpp:66
immer::flex_vector< KazvEvent > nextTriggers
Definition: client-model.hpp:82
std::string token
Definition: client-model.hpp:62
std::string nextTxnId
Definition: client-model.hpp:80
constexpr auto job() const
Definition: client-model.hpp:166
bool loggedIn
Definition: client-model.hpp:64
EventList toDevice
Definition: client-model.hpp:84
std::pair< Event, std::optional< std::string > > megOlmEncrypt(Event e, std::string roomId, Timestamp timeMs, RandomData random)
Definition: client-model.cpp:125
immer::map< std::string, immer::map< std::string, Event > > olmEncryptSplit(Event e, immer::map< std::string, immer::flex_vector< std::string >> userIdToDeviceIdMap, RandomData random)
precondition: the one-time keys for those devices must already be claimed
Definition: client-model.cpp:177
auto roomIdsUnderTag(std::string tagId) const -> immer::map< std::string, double >
Definition: client-model.cpp:385
std::optional< std::string > syncToken
Definition: client-model.hpp:74
std::string deviceId
Definition: client-model.hpp:63
Definition: client-model.hpp:299
std::optional< std::string > name
Definition: client-model.hpp:304
JsonWrap creationContent
Definition: client-model.hpp:309
immer::array< std::string > invite
Definition: client-model.hpp:306
std::optional< Preset > preset
Definition: client-model.hpp:311
std::optional< std::string > roomVersion
Definition: client-model.hpp:308
std::optional< std::string > roomAliasName
Definition: client-model.hpp:303
std::optional< bool > isDirect
Definition: client-model.hpp:312
JsonWrap powerLevelContentOverride
Definition: client-model.hpp:313
Visibility visibility
Definition: client-model.hpp:302
immer::array< Event > initialState
Definition: client-model.hpp:310
std::optional< std::string > topic
Definition: client-model.hpp:305
Definition: device-list-tracker.hpp:59
Definition: client-model.hpp:409
std::string mxcUri
Definition: client-model.hpp:410
std::optional< FileDesc > downloadTo
Definition: client-model.hpp:411
Definition: client-model.hpp:415
std::string mxcUri
Definition: client-model.hpp:416
std::optional< FileDesc > downloadTo
Definition: client-model.hpp:421
std::optional< ThumbnailResizingMethod > method
Definition: client-model.hpp:419
std::optional< bool > allowRemote
Definition: client-model.hpp:420
int width
Definition: client-model.hpp:417
int height
Definition: client-model.hpp:418
The action to encrypt an megolm event for a room.
Definition: client-model.hpp:519
static std::size_t maxRandomSize()
Definition: client-model.cpp:276
static std::size_t minRandomSize()
Definition: client-model.cpp:281
Event e
The event to encrypt.
Definition: client-model.hpp:526
RandomData random
Random data for the operation.
Definition: client-model.hpp:532
Timestamp timeMs
The timestamp, to determine whether the session should expire.
Definition: client-model.hpp:528
std::string roomId
The id of the room to encrypt for.
Definition: client-model.hpp:524
Definition: client-model.hpp:351
std::string roomId
Definition: client-model.hpp:352
The action to generate one-time keys.
Definition: client-model.hpp:475
static std::size_t randomSize(std::size_t numToGen)
Definition: client-model.cpp:294
RandomData random
The random data used to generate keys.
Definition: client-model.hpp:482
std::size_t numToGen
The number of keys to generate.
Definition: client-model.hpp:480
Definition: client-model.hpp:317
std::string roomId
Definition: client-model.hpp:318
Definition: client-model.hpp:322
std::string stateKey
Definition: client-model.hpp:325
std::string type
Definition: client-model.hpp:324
std::string roomId
Definition: client-model.hpp:323
Definition: client-model.hpp:567
std::string userId
Definition: client-model.hpp:568
Definition: client-model.hpp:226
std::string serverUrl
Definition: client-model.hpp:227
Definition: client-model.hpp:221
std::string userId
Definition: client-model.hpp:222
Definition: client-model.hpp:218
Definition: client-model.hpp:329
std::string userId
Definition: client-model.hpp:331
std::string roomId
Definition: client-model.hpp:330
Definition: client-model.hpp:340
immer::array< std::string > serverName
Definition: client-model.hpp:342
std::string roomIdOrAlias
Definition: client-model.hpp:341
Definition: client-model.hpp:335
std::string roomId
Definition: client-model.hpp:336
Definition: client-model.hpp:356
std::string roomId
Definition: client-model.hpp:357
std::string userId
Definition: client-model.hpp:358
std::optional< std::string > reason
Definition: client-model.hpp:359
Definition: client-model.hpp:346
std::string roomId
Definition: client-model.hpp:347
Status
Definition: local-echo.hpp:21
Definition: client-model.hpp:202
std::string password
Definition: client-model.hpp:205
std::string serverUrl
Definition: client-model.hpp:203
std::string username
Definition: client-model.hpp:204
std::optional< std::string > deviceName
Definition: client-model.hpp:206
Definition: client-model.hpp:217
Definition: client-model.hpp:238
std::string fromEventId
Must be where the Gap is.
Definition: client-model.hpp:241
std::optional< int > limit
Definition: client-model.hpp:242
std::string roomId
Definition: client-model.hpp:239
Definition: client-model.hpp:435
Definition: client-model.hpp:389
std::string eventId
Definition: client-model.hpp:391
std::string roomId
Definition: client-model.hpp:390
Encrypt room key as olm and add it to the room's pending keyshare slots.
Definition: client-model.hpp:551
immer::map< std::string, immer::flex_vector< std::string > > UserIdToDeviceIdMap
Definition: client-model.hpp:552
Event e
The key event to encrypt.
Definition: client-model.hpp:560
UserIdToDeviceIdMap devices
Devices to encrypt for.
Definition: client-model.hpp:558
std::string roomId
The room to share the key event in.
Definition: client-model.hpp:556
RandomData random
The random data for the encryption.
Definition: client-model.hpp:563
static std::size_t randomSize(UserIdToDeviceIdMap devices)
Definition: client-model.cpp:286
Definition: client-model.hpp:430
Response response
Definition: client-model.hpp:431
Definition: client-model.hpp:486
bool isInitialSync
Definition: client-model.hpp:487
Definition: client-model.hpp:292
std::string eventId
Definition: client-model.hpp:294
std::optional< std::string > reason
Definition: client-model.hpp:295
std::string roomId
Definition: client-model.hpp:293
Definition: basejob.hpp:50
Definition: client-model.hpp:425
BaseJob job
Definition: client-model.hpp:426
Definition: room-model.hpp:398
Saves an local echo.
Definition: client-model.hpp:266
std::string roomId
The room id.
Definition: client-model.hpp:268
std::optional< std::string > txnId
The chosen txnId for this event. If not specified, generate from the current ClientModel.
Definition: client-model.hpp:272
Event event
The event to send.
Definition: client-model.hpp:270
Definition: client-model.hpp:246
std::optional< std::string > txnId
Definition: client-model.hpp:249
std::string roomId
Definition: client-model.hpp:247
Event event
Definition: client-model.hpp:248
Send multiple to device messages.
Definition: client-model.hpp:456
std::optional< std::string > txnId
An optional transaction id. Will be generated if not provided.
Definition: client-model.hpp:460
immer::map< std::string, immer::map< std::string, Event > > userToDeviceToEventMap
A map from user id to device id to the event.
Definition: client-model.hpp:458
Definition: client-model.hpp:253
Event event
Definition: client-model.hpp:255
std::string roomId
Definition: client-model.hpp:254
Definition: client-model.hpp:444
immer::map< std::string, immer::flex_vector< std::string > > devicesToSend
Definition: client-model.hpp:446
std::optional< std::string > txnId
Definition: client-model.hpp:447
Event event
Definition: client-model.hpp:445
Definition: client-model.hpp:439
Event accountDataEvent
Definition: client-model.hpp:440
Definition: client-model.hpp:376
std::string roomId
Definition: client-model.hpp:377
Event accountDataEvent
Definition: client-model.hpp:378
Definition: client-model.hpp:572
std::optional< std::string > avatarUrl
Definition: client-model.hpp:573
Definition: client-model.hpp:536
std::string userId
Definition: client-model.hpp:537
DeviceTrustLevel trustLevel
Definition: client-model.hpp:539
std::string deviceId
Definition: client-model.hpp:538
Definition: client-model.hpp:577
std::optional< std::string > displayName
Definition: client-model.hpp:578
Definition: client-model.hpp:395
std::string eventId
Definition: client-model.hpp:397
std::string roomId
Definition: client-model.hpp:396
Definition: client-model.hpp:233
bool shouldSync
Definition: client-model.hpp:234
Definition: client-model.hpp:543
DeviceTrustLevel trustLevel
Definition: client-model.hpp:544
Definition: client-model.hpp:382
bool typing
Definition: client-model.hpp:384
std::optional< int > timeoutMs
Definition: client-model.hpp:385
std::string roomId
Definition: client-model.hpp:383
Definition: client-model.hpp:230
Definition: client-model.hpp:210
std::string username
Definition: client-model.hpp:212
std::string serverUrl
Definition: client-model.hpp:211
std::string deviceId
Definition: client-model.hpp:214
std::string token
Definition: client-model.hpp:213
Definition: client-model.hpp:370
std::string roomId
Definition: client-model.hpp:371
std::string userId
Definition: client-model.hpp:372
Updates the status of an local echo.
Definition: client-model.hpp:282
std::string roomId
The room id.
Definition: client-model.hpp:284
LocalEchoDesc::Status status
The updated status of this local echo.
Definition: client-model.hpp:288
std::string txnId
The chosen txnId for this event.
Definition: client-model.hpp:286
Definition: client-model.hpp:401
std::string uploadId
Definition: client-model.hpp:405
std::optional< std::string > contentType
Definition: client-model.hpp:404
std::optional< std::string > filename
Definition: client-model.hpp:403
FileDesc content
Definition: client-model.hpp:402
Definition: client-model.hpp:464