Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3528027
D4793.id16324.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D4793.id16324.diff
View Options
diff --git a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/DatabaseQueryExecutor.h
@@ -58,6 +58,8 @@
virtual void storeOlmPersistData(crypto::Persist persist) const = 0;
virtual void setNotifyToken(std::string token) const = 0;
virtual void clearNotifyToken() const = 0;
+ virtual void setCurrentUserID(std::string userID) const = 0;
+ virtual std::string getCurrentUserID() const = 0;
virtual void clearSensitiveData() const = 0;
};
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.h
@@ -58,6 +58,8 @@
void storeOlmPersistData(crypto::Persist persist) const override;
void setNotifyToken(std::string token) const override;
void clearNotifyToken() const override;
+ void setCurrentUserID(std::string userID) const override;
+ std::string getCurrentUserID() const override;
void clearSensitiveData() const override;
};
diff --git a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
--- a/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
+++ b/native/cpp/CommonCpp/DatabaseManagers/SQLiteQueryExecutor.cpp
@@ -835,6 +835,21 @@
SQLiteQueryExecutor::getStorage().remove<Metadata>("notify_token");
}
+void SQLiteQueryExecutor::setCurrentUserID(std::string userID) const {
+ Metadata entry{
+ "current_user_id",
+ userID,
+ };
+ SQLiteQueryExecutor::getStorage().replace(entry);
+}
+
+std::string SQLiteQueryExecutor::getCurrentUserID() const {
+ std::unique_ptr<Metadata> currentUserID =
+ SQLiteQueryExecutor::getStorage().get_pointer<Metadata>(
+ "current_user_id");
+ return (currentUserID == nullptr) ? "" : currentUserID->data;
+}
+
void SQLiteQueryExecutor::clearSensitiveData() const {
if (file_exists(SQLiteQueryExecutor::sqliteFilePath) &&
std::remove(SQLiteQueryExecutor::sqliteFilePath.c_str())) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 8:01 AM (11 h, 31 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700577
Default Alt Text
D4793.id16324.diff (2 KB)
Attached To
Mode
D4793: Implement methods in SQLiteQueryExecutor and DatabaseQueryExecutor to store and retrieve current_user_id from SQLite
Attached
Detach File
Event Timeline
Log In to Comment