diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp --- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp +++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp @@ -814,48 +814,41 @@ notifsPrekeyToUpload = this->notifsCryptoModule->getPrekey(); } - std::string prekeyUploadError; - try { std::string contentPrekeySignature = this->contentCryptoModule->getPrekeySignature(); std::string notifsPrekeySignature = this->notifsCryptoModule->getPrekeySignature(); - try { - std::promise prekeyPromise; - std::future prekeyFuture = - prekeyPromise.get_future(); - RustPromiseManager::CPPPromiseInfo promiseInfo = { - std::move(prekeyPromise)}; - auto currentID = RustPromiseManager::instance.addPromise( - std::move(promiseInfo)); - auto contentPrekeyToUploadRust = - rust::String(parseOLMPrekey(contentPrekeyToUpload)); - auto prekeySignatureRust = rust::string(contentPrekeySignature); - auto notifsPrekeyToUploadRust = - rust::String(parseOLMPrekey(notifsPrekeyToUpload)); - auto notificationsPrekeySignatureRust = - rust::string(notifsPrekeySignature); - ::identityRefreshUserPrekeys( - authUserIDRust, - authDeviceIDRust, - authAccessTokenRust, - contentPrekeyToUploadRust, - prekeySignatureRust, - notifsPrekeyToUploadRust, - notificationsPrekeySignatureRust, - currentID); - prekeyFuture.get(); - } catch (const std::exception &e) { - prekeyUploadError = e.what(); - } + std::promise prekeyPromise; + std::future prekeyFuture = + prekeyPromise.get_future(); + RustPromiseManager::CPPPromiseInfo promiseInfo = { + std::move(prekeyPromise)}; + auto currentID = + RustPromiseManager::instance.addPromise(std::move(promiseInfo)); + auto contentPrekeyToUploadRust = + rust::String(parseOLMPrekey(contentPrekeyToUpload)); + auto prekeySignatureRust = rust::string(contentPrekeySignature); + auto notifsPrekeyToUploadRust = + rust::String(parseOLMPrekey(notifsPrekeyToUpload)); + auto notificationsPrekeySignatureRust = + rust::string(notifsPrekeySignature); + + this->contentCryptoModule->markPrekeyAsPublished(); + this->notifsCryptoModule->markPrekeyAsPublished(); + this->persistCryptoModules(true, true); - if (!prekeyUploadError.size()) { - this->contentCryptoModule->markPrekeyAsPublished(); - this->notifsCryptoModule->markPrekeyAsPublished(); - this->persistCryptoModules(true, true); - } + ::identityRefreshUserPrekeys( + authUserIDRust, + authDeviceIDRust, + authAccessTokenRust, + contentPrekeyToUploadRust, + prekeySignatureRust, + notifsPrekeyToUploadRust, + notificationsPrekeySignatureRust, + currentID); + prekeyFuture.get(); } catch (std::exception &e) { error = e.what(); } @@ -865,10 +858,6 @@ promise->reject(error); return; } - if (prekeyUploadError.size()) { - promise->reject(prekeyUploadError); - return; - } promise->resolve(jsi::Value::undefined()); }); }; @@ -911,6 +900,9 @@ if (!notifPrekeyBlob) { notifPrekeyBlob = this->notifsCryptoModule->getPrekey(); } + + this->contentCryptoModule->markPrekeyAsPublished(); + this->notifsCryptoModule->markPrekeyAsPublished(); this->persistCryptoModules(true, true); contentPrekeySignature = diff --git a/web/shared-worker/worker/worker-crypto.js b/web/shared-worker/worker/worker-crypto.js --- a/web/shared-worker/worker/worker-crypto.js +++ b/web/shared-worker/worker/worker-crypto.js @@ -698,14 +698,15 @@ throw new Error('Prekey signature is missing'); } + contentAccount.mark_prekey_as_published(); + notificationAccount.mark_prekey_as_published(); + await identityClient.publishWebPrekeys({ contentPrekey, contentPrekeySignature, notifPrekey, notifPrekeySignature, }); - contentAccount.mark_prekey_as_published(); - notificationAccount.mark_prekey_as_published(); persistCryptoStore(); },