Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3353138
D5316.id17447.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D5316.id17447.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
@@ -23,6 +23,10 @@
* 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<Thread> 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,6 +13,9 @@
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
@@ -878,30 +878,38 @@
}
void SQLiteQueryExecutor::setNotifyToken(std::string token) const {
- Metadata entry{
- "notify_token",
- token,
- };
- SQLiteQueryExecutor::getStorage().replace(entry);
+ this->setMetadata("notify_token", token);
}
void SQLiteQueryExecutor::clearNotifyToken() const {
- SQLiteQueryExecutor::getStorage().remove<Metadata>("notify_token");
+ this->clearMetadata("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{
- "current_user_id",
- userID,
+ entry_name,
+ data,
};
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::clearMetadata(std::string entry_name) const {
+ SQLiteQueryExecutor::getStorage().remove<Metadata>(entry_name);
+}
+
+std::string SQLiteQueryExecutor::getMetadata(std::string entry_name) const {
+ std::unique_ptr<Metadata> entry =
+ SQLiteQueryExecutor::getStorage().get_pointer<Metadata>(entry_name);
+ return (entry == nullptr) ? "" : entry->data;
}
void SQLiteQueryExecutor::clearSensitiveData() const {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 8:32 AM (20 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2574696
Default Alt Text
D5316.id17447.diff (3 KB)
Attached To
Mode
D5316: Refactor some SQLiteQueryExecutor code
Attached
Detach File
Event Timeline
Log In to Comment