| 548 | } |
| 549 | |
| 550 | void CommCoreModule::persistCryptoModules( |
| 551 | bool persistContentModule, |
| 552 | std::optional<std::pair<std::shared_ptr<crypto::CryptoModule>, std::string>> |
| 553 | maybeUpdatedNotifsCryptoModule) { |
| 554 | std::string storedSecretKey = getAccountDataKey(secureStoreAccountDataKey); |
| 555 | |
| 556 | if (!persistContentModule && !maybeUpdatedNotifsCryptoModule.has_value()) { |
| 557 | return; |
| 558 | } |
| 559 | |
| 560 | crypto::Persist newContentPersist; |
| 561 | if (persistContentModule) { |
| 562 | newContentPersist = this->contentCryptoModule->storeAsB64(storedSecretKey); |
| 563 | } |
| 564 | |
| 565 | std::promise<void> persistencePromise; |
| 566 | std::future<void> persistenceFuture = persistencePromise.get_future(); |
| 567 | GlobalDBSingleton::instance.scheduleOrRunCancellable( |
| 568 | [=, &persistencePromise]() { |
| 569 | try { |
| 570 | DatabaseManager::getQueryExecutor().beginTransaction(); |
| 571 | if (persistContentModule) { |
| 572 | DatabaseManager::getQueryExecutor().storeOlmPersistData( |
| 573 | DatabaseManager::getQueryExecutor().getContentAccountID(), |
| 574 | newContentPersist); |
| 575 | } |
| 576 | if (maybeUpdatedNotifsCryptoModule.has_value()) { |
| 577 | NotificationsCryptoModule::persistNotificationsAccount( |
| 578 | maybeUpdatedNotifsCryptoModule.value().first, |
| 579 | maybeUpdatedNotifsCryptoModule.value().second, |
| 580 | true); |
| 581 | } |
| 582 | DatabaseManager::getQueryExecutor().commitTransaction(); |
| 583 | persistencePromise.set_value(); |
| 584 | } catch (std::system_error &e) { |
| 585 | DatabaseManager::getQueryExecutor().rollbackTransaction(); |
| 586 | persistencePromise.set_exception(std::make_exception_ptr(e)); |
| 587 | } |
| 588 | }); |
| 589 | persistenceFuture.get(); |
| 590 | } |
| 591 | |
| 592 | jsi::Value CommCoreModule::initializeCryptoAccount(jsi::Runtime &rt) { |
| 593 | folly::Optional<std::string> storedSecretKey = |
no test coverage detected