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("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 currentUserID = + SQLiteQueryExecutor::getStorage().get_pointer( + "current_user_id"); + return (currentUserID == nullptr) ? "" : currentUserID->data; +} + void SQLiteQueryExecutor::clearSensitiveData() const { if (file_exists(SQLiteQueryExecutor::sqliteFilePath) && std::remove(SQLiteQueryExecutor::sqliteFilePath.c_str())) {