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

Method encryptNotification

native/cpp/CommonCpp/NativeModules/CommCoreModule.cpp:1765–1795  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1763}
1764
1765jsi::Value CommCoreModule::encryptNotification(
1766 jsi::Runtime &rt,
1767 jsi::String payload,
1768 jsi::String deviceID) {
1769 auto payloadCpp{payload.utf8(rt)};
1770 auto deviceIDCpp{deviceID.utf8(rt)};
1771
1772 return createPromiseAsJSIValue(
1773 rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
1774 taskType job = [=, &innerRt]() {
1775 std::string error;
1776 crypto::EncryptedData result;
1777 try {
1778 result =
1779 NotificationsCryptoModule::encrypt(deviceIDCpp, payloadCpp);
1780 } catch (const std::exception &e) {
1781 error = e.what();
1782 }
1783
1784 this->jsInvoker_->invokeAsync([=, &innerRt]() {
1785 if (error.size()) {
1786 promise->reject(error);
1787 return;
1788 }
1789 auto encryptedDataJSI = parseEncryptedData(innerRt, result);
1790 promise->resolve(std::move(encryptedDataJSI));
1791 });
1792 };
1793 this->cryptoThread->scheduleTask(job);
1794 });
1795}
1796
1797jsi::Value CommCoreModule::encryptAndPersist(
1798 jsi::Runtime &rt,

Callers

nothing calls this directly

Calls 5

parseEncryptedDataFunction · 0.85
rejectMethod · 0.80
resolveMethod · 0.80
scheduleTaskMethod · 0.80
encryptFunction · 0.50

Tested by

no test coverage detected