MCPcopy Create free account
hub / github.com/CommE2E/comm / getOneTimeKeys

Method getOneTimeKeys

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp:877–917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

875}
876
877jsi::Value
878CommCoreModule::getOneTimeKeys(jsi::Runtime &rt, double oneTimeKeysAmount) {
879 return createPromiseAsJSIValue(
880 rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
881 taskType job = [=, &innerRt]() {
882 std::string error;
883 std::vector<std::string> contentResult;
884 std::vector<std::string> notifResult;
885 if (this->contentCryptoModule == nullptr ||
886 !NotificationsCryptoModule::isNotificationsAccountInitialized()) {
887 this->jsInvoker_->invokeAsync([=, &innerRt]() {
888 promise->reject("user has not been initialized");
889 });
890 return;
891 }
892 try {
893 contentResult =
894 this->contentCryptoModule->getOneTimeKeysForPublishing(
895 oneTimeKeysAmount);
896 std::pair<std::shared_ptr<crypto::CryptoModule>, std::string>
897 notifsCryptoModuleWithPicklingKey =
898 NotificationsCryptoModule::fetchNotificationsAccount()
899 .value();
900 notifResult = notifsCryptoModuleWithPicklingKey.first
901 ->getOneTimeKeysForPublishing(oneTimeKeysAmount);
902 this->persistCryptoModules(true, notifsCryptoModuleWithPicklingKey);
903 } catch (const std::exception &e) {
904 error = e.what();
905 }
906 this->jsInvoker_->invokeAsync([=, &innerRt]() {
907 if (error.size()) {
908 promise->reject(error);
909 return;
910 }
911 promise->resolve(
912 parseOneTimeKeysResult(innerRt, contentResult, notifResult));
913 });
914 };
915 this->cryptoThread->scheduleTask(job);
916 });
917}
918
919jsi::Value CommCoreModule::validateAndUploadPrekeys(
920 jsi::Runtime &rt,

Callers

nothing calls this directly

Calls 6

persistCryptoModulesMethod · 0.95
parseOneTimeKeysResultFunction · 0.85
rejectMethod · 0.80
resolveMethod · 0.80
scheduleTaskMethod · 0.80

Tested by

no test coverage detected