Changeset View
Changeset View
Standalone View
Standalone View
native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp
#include "CommCoreModule.h" | #include "CommCoreModule.h" | ||||
#include "../CryptoTools/DeviceID.h" | #include "../CryptoTools/DeviceID.h" | ||||
#include "DatabaseManager.h" | #include "DatabaseManager.h" | ||||
#include "DraftStoreOperations.h" | #include "DraftStoreOperations.h" | ||||
#include "InternalModules/GlobalDBSingleton.h" | #include "InternalModules/GlobalDBSingleton.h" | ||||
#include "MessageStoreOperations.h" | #include "MessageStoreOperations.h" | ||||
#include "TerminateApp.h" | |||||
#include "ThreadStoreOperations.h" | #include "ThreadStoreOperations.h" | ||||
#include <ReactCommon/TurboModuleUtils.h> | #include <ReactCommon/TurboModuleUtils.h> | ||||
#include <folly/dynamic.h> | #include <folly/dynamic.h> | ||||
#include <folly/json.h> | #include <folly/json.h> | ||||
#include <future> | #include <future> | ||||
namespace comm { | namespace comm { | ||||
▲ Show 20 Lines • Show All 701 Lines • ▼ Show 20 Lines | try { | ||||
DatabaseManager::getQueryExecutor().commitTransaction(); | DatabaseManager::getQueryExecutor().commitTransaction(); | ||||
} catch (const std::exception &e) { | } catch (const std::exception &e) { | ||||
DatabaseManager::getQueryExecutor().rollbackTransaction(); | DatabaseManager::getQueryExecutor().rollbackTransaction(); | ||||
throw e; | throw e; | ||||
} | } | ||||
}); | }); | ||||
} | } | ||||
void CommCoreModule::terminate(jsi::Runtime &rt) { | |||||
TerminateApp::terminate(); | |||||
} | |||||
jsi::Value | jsi::Value | ||||
CommCoreModule::initializeCryptoAccount(jsi::Runtime &rt, jsi::String userId) { | CommCoreModule::initializeCryptoAccount(jsi::Runtime &rt, jsi::String userId) { | ||||
std::string userIdStr = userId.utf8(rt); | std::string userIdStr = userId.utf8(rt); | ||||
folly::Optional<std::string> storedSecretKey = | folly::Optional<std::string> storedSecretKey = | ||||
this->secureStore.get(this->secureStoreAccountDataKey); | this->secureStore.get(this->secureStoreAccountDataKey); | ||||
if (!storedSecretKey.hasValue()) { | if (!storedSecretKey.hasValue()) { | ||||
storedSecretKey = crypto::Tools::generateRandomString(64); | storedSecretKey = crypto::Tools::generateRandomString(64); | ||||
this->secureStore.set( | this->secureStore.set( | ||||
▲ Show 20 Lines • Show All 338 Lines • Show Last 20 Lines |