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 @@ -23,10 +23,6 @@ * following the RAII pattern */ class DatabaseQueryExecutor { - virtual void setMetadata(std::string entry_name, std::string data) const = 0; - virtual void clearMetadata(std::string entry_name) const = 0; - virtual std::string getMetadata(std::string entry_name) const = 0; - public: virtual std::string getDraft(std::string key) const = 0; virtual std::unique_ptr getThread(std::string threadID) 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 @@ -13,9 +13,6 @@ void migrate() const; static void assign_encryption_key(); static auto &getStorage(); - void setMetadata(std::string entry_name, std::string data) const override; - void clearMetadata(std::string entry_name) const override; - std::string getMetadata(std::string entry_name) const override; static std::once_flag initialized; static int sqlcipherEncryptionKeySize; 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 @@ -899,38 +899,30 @@ } void SQLiteQueryExecutor::setNotifyToken(std::string token) const { - this->setMetadata("notify_token", token); + Metadata entry{ + "notify_token", + token, + }; + SQLiteQueryExecutor::getStorage().replace(entry); } void SQLiteQueryExecutor::clearNotifyToken() const { - this->clearMetadata("notify_token"); + SQLiteQueryExecutor::getStorage().remove("notify_token"); } void SQLiteQueryExecutor::setCurrentUserID(std::string userID) const { - this->setMetadata("current_user_id", userID); -} - -std::string SQLiteQueryExecutor::getCurrentUserID() const { - return this->getMetadata("current_user_id"); -} - -void SQLiteQueryExecutor::setMetadata(std::string entry_name, std::string data) - const { Metadata entry{ - entry_name, - data, + "current_user_id", + userID, }; SQLiteQueryExecutor::getStorage().replace(entry); } -void SQLiteQueryExecutor::clearMetadata(std::string entry_name) const { - SQLiteQueryExecutor::getStorage().remove(entry_name); -} - -std::string SQLiteQueryExecutor::getMetadata(std::string entry_name) const { - std::unique_ptr entry = - SQLiteQueryExecutor::getStorage().get_pointer(entry_name); - return (entry == nullptr) ? "" : entry->data; +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 {