Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3243807
D4794.id16325.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D4794.id16325.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
@@ -58,6 +58,9 @@
jsi::Value
setNotifyToken(jsi::Runtime &rt, const jsi::String &token) override;
jsi::Value clearNotifyToken(jsi::Runtime &rt) override;
+ jsi::Value
+ setCurrentUserID(jsi::Runtime &rt, const jsi::String &userID) override;
+ jsi::Value getCurrentUserID(jsi::Runtime &rt) override;
jsi::Value clearSensitiveData(jsi::Runtime &rt) override;
public:
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
@@ -955,6 +955,53 @@
});
};
+jsi::Value
+CommCoreModule::setCurrentUserID(jsi::Runtime &rt, const jsi::String &userID) {
+ auto currentUserID{userID.utf8(rt)};
+ return createPromiseAsJSIValue(
+ rt,
+ [this,
+ currentUserID](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ this->databaseThread->scheduleTask([this, promise, currentUserID]() {
+ std::string error;
+ try {
+ DatabaseManager::getQueryExecutor().setCurrentUserID(currentUserID);
+ } catch (const std::exception &e) {
+ error = e.what();
+ }
+ this->jsInvoker_->invokeAsync([error, promise]() {
+ if (error.size()) {
+ promise->reject(error);
+ } else {
+ promise->resolve(jsi::Value::undefined());
+ }
+ });
+ });
+ });
+}
+
+jsi::Value CommCoreModule::getCurrentUserID(jsi::Runtime &rt) {
+ return createPromiseAsJSIValue(
+ rt, [this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
+ this->databaseThread->scheduleTask([this, &innerRt, promise]() {
+ std::string error;
+ std::string result;
+ try {
+ result = DatabaseManager::getQueryExecutor().getCurrentUserID();
+ } catch (const std::exception &e) {
+ error = e.what();
+ }
+ this->jsInvoker_->invokeAsync([&innerRt, error, result, promise]() {
+ if (error.size()) {
+ promise->reject(error);
+ } else {
+ promise->resolve(jsi::String::createFromUtf8(innerRt, result));
+ }
+ });
+ });
+ });
+}
+
jsi::Value CommCoreModule::clearSensitiveData(jsi::Runtime &rt) {
return createPromiseAsJSIValue(
rt, [this](jsi::Runtime &innerRt, std::shared_ptr<Promise> promise) {
diff --git a/native/cpp/CommonCpp/_generated/NativeModules.h b/native/cpp/CommonCpp/_generated/NativeModules.h
--- a/native/cpp/CommonCpp/_generated/NativeModules.h
+++ b/native/cpp/CommonCpp/_generated/NativeModules.h
@@ -38,6 +38,8 @@
virtual double getCodeVersion(jsi::Runtime &rt) = 0;
virtual jsi::Value setNotifyToken(jsi::Runtime &rt, const jsi::String &token) = 0;
virtual jsi::Value clearNotifyToken(jsi::Runtime &rt) = 0;
+virtual jsi::Value setCurrentUserID(jsi::Runtime &rt, const jsi::String &userID) = 0;
+virtual jsi::Value getCurrentUserID(jsi::Runtime &rt) = 0;
virtual jsi::Value clearSensitiveData(jsi::Runtime &rt) = 0;
};
diff --git a/native/cpp/CommonCpp/_generated/NativeModules.cpp b/native/cpp/CommonCpp/_generated/NativeModules.cpp
--- a/native/cpp/CommonCpp/_generated/NativeModules.cpp
+++ b/native/cpp/CommonCpp/_generated/NativeModules.cpp
@@ -72,6 +72,12 @@
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearNotifyToken(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->clearNotifyToken(rt);
}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setCurrentUserID(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->setCurrentUserID(rt, args[0].getString(rt));
+}
+static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCurrentUserID(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
+ return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->getCurrentUserID(rt);
+}
static jsi::Value __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearSensitiveData(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
return static_cast<CommCoreModuleSchemaCxxSpecJSI *>(&turboModule)->clearSensitiveData(rt);
}
@@ -98,6 +104,8 @@
methodMap_["getCodeVersion"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCodeVersion};
methodMap_["setNotifyToken"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setNotifyToken};
methodMap_["clearNotifyToken"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearNotifyToken};
+ methodMap_["setCurrentUserID"] = MethodMetadata {1, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_setCurrentUserID};
+ methodMap_["getCurrentUserID"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_getCurrentUserID};
methodMap_["clearSensitiveData"] = MethodMetadata {0, __hostFunction_CommCoreModuleSchemaCxxSpecJSI_clearSensitiveData};
}
diff --git a/native/schema/CommCoreModuleSchema.js b/native/schema/CommCoreModuleSchema.js
--- a/native/schema/CommCoreModuleSchema.js
+++ b/native/schema/CommCoreModuleSchema.js
@@ -48,6 +48,8 @@
+getCodeVersion: () => number;
+setNotifyToken: (token: string) => Promise<void>;
+clearNotifyToken: () => Promise<void>;
+ +setCurrentUserID: (userID: string) => Promise<void>;
+ +getCurrentUserID: () => Promise<string>;
+clearSensitiveData: () => Promise<void>;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 9:25 AM (18 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2493976
Default Alt Text
D4794.id16325.diff (5 KB)
Attached To
Mode
D4794: Implement methods to store and retrieve current_user_id from database in CommCoreModule
Attached
Detach File
Event Timeline
Log In to Comment