Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33424087
D13899.1769004832.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D13899.1769004832.diff
View Options
diff --git a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
--- a/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
+++ b/native/cpp/CommonCpp/NativeModules/CommCoreModule.h
@@ -248,6 +248,8 @@
virtual jsi::Value
getOutboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) override;
virtual jsi::Value getAllOutboundP2PMessages(jsi::Runtime &rt) override;
+ virtual jsi::Value
+ getInboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) override;
virtual jsi::Value markOutboundP2PMessageAsSent(
jsi::Runtime &rt,
jsi::String messageID,
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
@@ -882,6 +882,23 @@
return encryptedDataJSI;
}
+jsi::Array parseInboundingMessages(
+ jsi::Runtime &rt,
+ std::shared_ptr<std::vector<InboundP2PMessage>> messagesPtr) {
+ jsi::Array jsiMessages = jsi::Array(rt, messagesPtr->size());
+ size_t writeIdx = 0;
+ for (const InboundP2PMessage &msg : *messagesPtr) {
+ jsi::Object jsiMsg = jsi::Object(rt);
+ jsiMsg.setProperty(rt, "messageID", msg.message_id);
+ jsiMsg.setProperty(rt, "senderDeviceID", msg.sender_device_id);
+ jsiMsg.setProperty(rt, "plaintext", msg.plaintext);
+ jsiMsg.setProperty(rt, "status", msg.status);
+ jsiMsg.setProperty(rt, "senderUserID", msg.sender_user_id);
+ jsiMessages.setValueAtIndex(rt, writeIdx++, jsiMsg);
+ }
+ return jsiMessages;
+}
+
jsi::Value
CommCoreModule::getOneTimeKeys(jsi::Runtime &rt, double oneTimeKeysAmount) {
return createPromiseAsJSIValue(
@@ -2729,19 +2746,7 @@
}
jsi::Array jsiMessages =
- jsi::Array(innerRt, messagesPtr->size());
- size_t writeIdx = 0;
- for (const InboundP2PMessage &msg : *messagesPtr) {
- jsi::Object jsiMsg = jsi::Object(innerRt);
- jsiMsg.setProperty(innerRt, "messageID", msg.message_id);
- jsiMsg.setProperty(
- innerRt, "senderDeviceID", msg.sender_device_id);
- jsiMsg.setProperty(innerRt, "plaintext", msg.plaintext);
- jsiMsg.setProperty(innerRt, "status", msg.status);
- jsiMsg.setProperty(
- innerRt, "senderUserID", msg.sender_user_id);
- jsiMessages.setValueAtIndex(innerRt, writeIdx++, jsiMsg);
- }
+ parseInboundingMessages(innerRt, messagesPtr);
promise->resolve(std::move(jsiMessages));
});
@@ -2784,6 +2789,48 @@
});
}
+jsi::Value
+CommCoreModule::getInboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) {
+ std::vector<std::string> msgIDsCPP{};
+ for (auto idx = 0; idx < ids.size(rt); idx++) {
+ std::string msgID = ids.getValueAtIndex(rt, idx).asString(rt).utf8(rt);
+ msgIDsCPP.push_back(msgID);
+ }
+
+ return createPromiseAsJSIValue(
+ rt, [=](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ taskType job = [=, &innerRt]() {
+ std::string error;
+ std::vector<InboundP2PMessage> messages;
+
+ try {
+ messages =
+ DatabaseManager::getQueryExecutor().getInboundP2PMessagesByID(
+ msgIDsCPP);
+ } catch (std::system_error &e) {
+ error = e.what();
+ }
+ auto messagesPtr = std::make_shared<std::vector<InboundP2PMessage>>(
+ std::move(messages));
+
+ this->jsInvoker_->invokeAsync(
+ [&innerRt, messagesPtr, error, promise]() {
+ if (error.size()) {
+ promise->reject(error);
+ return;
+ }
+
+ jsi::Array jsiMessages =
+ parseInboundingMessages(innerRt, messagesPtr);
+
+ promise->resolve(std::move(jsiMessages));
+ });
+ };
+ GlobalDBSingleton::instance.scheduleOrRunCancellable(
+ job, promise, this->jsInvoker_);
+ });
+}
+
jsi::Value
CommCoreModule::getOutboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) {
std::vector<std::string> msgIDsCPP{};
diff --git a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
--- a/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
+++ b/native/cpp/CommonCpp/_generated/commJSI-generated.cpp
@@ -211,6 +211,9 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeInboundP2PMessages(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->removeInboundP2PMessages(rt, args[0].asObject(rt).asArray(rt));
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getInboundP2PMessagesByID(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getInboundP2PMessagesByID(rt, args[0].asObject(rt).asArray(rt));
+}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getOutboundP2PMessagesByID(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getOutboundP2PMessagesByID(rt, args[0].asObject(rt).asArray(rt));
}
@@ -308,6 +311,7 @@
methodMap_["getSIWEBackupSecrets"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getSIWEBackupSecrets};
methodMap_["getAllInboundP2PMessages"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllInboundP2PMessages};
methodMap_["removeInboundP2PMessages"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_removeInboundP2PMessages};
+ methodMap_["getInboundP2PMessagesByID"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getInboundP2PMessagesByID};
methodMap_["getOutboundP2PMessagesByID"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getOutboundP2PMessagesByID};
methodMap_["getAllOutboundP2PMessages"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getAllOutboundP2PMessages};
methodMap_["markOutboundP2PMessageAsSent"] = MethodMetadata {2, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_markOutboundP2PMessageAsSent};
diff --git a/native/cpp/CommonCpp/_generated/commJSI.h b/native/cpp/CommonCpp/_generated/commJSI.h
--- a/native/cpp/CommonCpp/_generated/commJSI.h
+++ b/native/cpp/CommonCpp/_generated/commJSI.h
@@ -84,6 +84,7 @@
virtual jsi::Value getSIWEBackupSecrets(jsi::Runtime &rt) = 0;
virtual jsi::Value getAllInboundP2PMessages(jsi::Runtime &rt) = 0;
virtual jsi::Value removeInboundP2PMessages(jsi::Runtime &rt, jsi::Array ids) = 0;
+ virtual jsi::Value getInboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) = 0;
virtual jsi::Value getOutboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) = 0;
virtual jsi::Value getAllOutboundP2PMessages(jsi::Runtime &rt) = 0;
virtual jsi::Value markOutboundP2PMessageAsSent(jsi::Runtime &rt, jsi::String messageID, jsi::String deviceID) = 0;
@@ -627,6 +628,14 @@
return bridging::callFromJs<jsi::Value>(
rt, &T::removeInboundP2PMessages, jsInvoker_, instance_, std::move(ids));
}
+ jsi::Value getInboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) override {
+ static_assert(
+ bridging::getParameterCount(&T::getInboundP2PMessagesByID) == 2,
+ "Expected getInboundP2PMessagesByID(...) to have 2 parameters");
+
+ return bridging::callFromJs<jsi::Value>(
+ rt, &T::getInboundP2PMessagesByID, jsInvoker_, instance_, std::move(ids));
+ }
jsi::Value getOutboundP2PMessagesByID(jsi::Runtime &rt, jsi::Array ids) override {
static_assert(
bridging::getParameterCount(&T::getOutboundP2PMessagesByID) == 2,
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -181,6 +181,9 @@
+getSIWEBackupSecrets: () => Promise<?Object>;
+getAllInboundP2PMessages: () => Promise<Array<InboundP2PMessage>>;
+removeInboundP2PMessages: (ids: $ReadOnlyArray<string>) => Promise<void>;
+ +getInboundP2PMessagesByID: (
+ ids: $ReadOnlyArray<string>,
+ ) => Promise<Array<InboundP2PMessage>>;
+getOutboundP2PMessagesByID: (
ids: $ReadOnlyArray<string>,
) => Promise<Array<OutboundP2PMessage>>;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 21, 2:13 PM (3 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5969163
Default Alt Text
D13899.1769004832.diff (8 KB)
Attached To
Mode
D13899: [native] Implement getInboundP2PMessagesByID query in JSI
Attached
Detach File
Event Timeline
Log In to Comment