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

Method markPrekeysAsPublished

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp:3242–3281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3240}
3241
3242jsi::Value CommCoreModule::markPrekeysAsPublished(jsi::Runtime &rt) {
3243 return createPromiseAsJSIValue(
3244 rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
3245 taskType job = [=, &innerRt]() {
3246 std::string error;
3247
3248 if (this->contentCryptoModule == nullptr ||
3249 !NotificationsCryptoModule::isNotificationsAccountInitialized()) {
3250 this->jsInvoker_->invokeAsync([=, &innerRt]() {
3251 promise->reject("user has not been initialized");
3252 });
3253 return;
3254 }
3255
3256 std::optional<
3257 std::pair<std::shared_ptr<crypto::CryptoModule>, std::string>>
3258 notifsCryptoModuleWithPicklingKey;
3259 try {
3260 notifsCryptoModuleWithPicklingKey =
3261 NotificationsCryptoModule::fetchNotificationsAccount();
3262 this->contentCryptoModule->markPrekeyAsPublished();
3263 notifsCryptoModuleWithPicklingKey.value()
3264 .first->markPrekeyAsPublished();
3265 this->persistCryptoModules(true, notifsCryptoModuleWithPicklingKey);
3266 } catch (std::exception &e) {
3267 error = e.what();
3268 }
3269
3270 this->jsInvoker_->invokeAsync([=]() {
3271 if (error.size()) {
3272 promise->reject(error);
3273 return;
3274 }
3275 promise->resolve(jsi::Value::undefined());
3276 });
3277 };
3278
3279 this->cryptoThread->scheduleTask(job);
3280 });
3281}
3282
3283jsi::Value
3284CommCoreModule::getRelatedMessages(jsi::Runtime &rt, jsi::String messageID) {

Callers

nothing calls this directly

Calls 5

persistCryptoModulesMethod · 0.95
rejectMethod · 0.80
markPrekeyAsPublishedMethod · 0.80
resolveMethod · 0.80
scheduleTaskMethod · 0.80

Tested by

no test coverage detected