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 @@ -6,6 +6,7 @@ #include "entities/KeyserverInfo.h" #include "entities/Message.h" #include "entities/MessageStoreThread.h" +#include "entities/MessageToDevice.h" #include "entities/OlmPersistAccount.h" #include "entities/OlmPersistSession.h" #include "entities/PersistItem.h" @@ -98,6 +99,8 @@ std::string mainCompactionEncryptionKey) const = 0; virtual void restoreFromBackupLog(const std::vector &backupLog) const = 0; + virtual void addMessagesToDevice( + const std::vector &messages) const = 0; #ifdef EMSCRIPTEN virtual std::vector 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 @@ -112,6 +112,8 @@ std::string mainCompactionEncryptionKey) const override; void restoreFromBackupLog( const std::vector &backupLog) const override; + void addMessagesToDevice( + const std::vector &messages) const override; #ifdef EMSCRIPTEN std::vector 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 @@ -1694,6 +1694,20 @@ return (entry == nullptr) ? "" : entry->data; } +void SQLiteQueryExecutor::addMessagesToDevice( + const std::vector &messages) const { + static std::string addMessageToDevice = + "REPLACE INTO messages_to_device (" + " message_id, device_id, user_id, timestamp, plaintext, ciphertext) " + "VALUES (?, ?, ?, ?, ?, ?);"; + + for (const ClientMessageToDevice &clientMessage : messages) { + MessageToDevice message = clientMessage.toMessageToDevice(); + replaceEntity( + SQLiteQueryExecutor::getConnection(), addMessageToDevice, message); + } +} + #ifdef EMSCRIPTEN std::vector 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$@