Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3526017
D11171.id.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
D11171.id.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
@@ -101,6 +101,8 @@
restoreFromBackupLog(const std::vector<std::uint8_t> &backupLog) const = 0;
virtual void addMessagesToDevice(
const std::vector<ClientMessageToDevice> &messages) const = 0;
+ virtual std::vector<ClientMessageToDevice>
+ getAllMessagesToDevice(const std::string &deviceID) const = 0;
#ifdef EMSCRIPTEN
virtual std::vector<WebThread> getAllThreadsWeb() 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
@@ -114,6 +114,8 @@
const std::vector<std::uint8_t> &backupLog) const override;
void addMessagesToDevice(
const std::vector<ClientMessageToDevice> &messages) const override;
+ std::vector<ClientMessageToDevice>
+ getAllMessagesToDevice(const std::string &deviceID) const override;
#ifdef EMSCRIPTEN
std::vector<WebThread> getAllThreadsWeb() 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
@@ -1708,6 +1708,29 @@
}
}
+std::vector<ClientMessageToDevice>
+SQLiteQueryExecutor::getAllMessagesToDevice(const std::string &deviceID) const {
+ std::string query =
+ "SELECT * FROM messages_to_device "
+ "WHERE device_id = ? "
+ "ORDER BY timestamp;";
+
+ SQLiteStatementWrapper preparedSQL(
+ SQLiteQueryExecutor::getConnection(),
+ query,
+ "Failed to get all messages to device");
+
+ sqlite3_bind_text(preparedSQL, 1, deviceID.c_str(), -1, SQLITE_TRANSIENT);
+
+ std::vector<ClientMessageToDevice> messages;
+ for (int stepResult = sqlite3_step(preparedSQL); stepResult == SQLITE_ROW;
+ stepResult = sqlite3_step(preparedSQL)) {
+ messages.emplace_back(
+ ClientMessageToDevice(MessageToDevice::fromSQLResult(preparedSQL, 0)));
+ }
+
+ return messages;
+}
#ifdef EMSCRIPTEN
std::vector<WebThread> SQLiteQueryExecutor::getAllThreadsWeb() const {
auto threads = this->getAllThreads();
diff --git a/web/database/_generated/comm_query_executor.wasm b/web/database/_generated/comm_query_executor.wasm
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
GIT binary patch
literal 0
Hc$@<O00001
literal 0
Hc$@<O00001
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 24, 7:12 PM (8 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2700865
Default Alt Text
D11171.id.diff (2 KB)
Attached To
Mode
D11171: [SQLite] implement getting `MessageToDevice` items
Attached
Detach File
Event Timeline
Log In to Comment