Page MenuHomePhabricator

D12778.id42353.diff
No OneTemporary

D12778.id42353.diff

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
@@ -168,6 +168,10 @@
virtual std::vector<InboundP2PMessage> getAllInboundP2PMessage() const = 0;
virtual void
removeInboundP2PMessages(const std::vector<std::string> &ids) const = 0;
+ virtual void updateMessageSearchResult(
+ std::string original_message_id,
+ std::string message_id,
+ std::string processed_content) 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
@@ -177,6 +177,10 @@
std::vector<InboundP2PMessage> getAllInboundP2PMessage() const override;
void
removeInboundP2PMessages(const std::vector<std::string> &ids) const override;
+ void updateMessageSearchResult(
+ std::string original_message_id,
+ std::string message_id,
+ std::string processed_content) 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
@@ -1433,6 +1433,54 @@
SQLiteQueryExecutor::getConnection(), replaceMessageSQL, message);
}
+void SQLiteQueryExecutor::updateMessageSearchResult(
+ std::string original_message_id,
+ std::string message_id,
+ std::string processed_content) const {
+
+ sqlite3 *db = SQLiteQueryExecutor::getConnection();
+ int bindResult = 0;
+ std::unique_ptr<SQLiteStatementWrapper> preparedSQL;
+
+ static std::string insertMessageSearchResultSQL =
+ "INSERT INTO message_search("
+ " original_message_id, message_id, processed_content) "
+ "VALUES (?, ?, ?);";
+ static std::string updateMessageSearchResultSQL =
+ "UPDATE message_search "
+ "SET message_id=?, processed_content=? "
+ "WHERE original_message_id=?;";
+
+ if (original_message_id == message_id) {
+ preparedSQL = std::make_unique<SQLiteStatementWrapper>(
+ db,
+ insertMessageSearchResultSQL,
+ "Failed to update message search entry.");
+
+ bindStringToSQL(original_message_id, *preparedSQL, 1);
+ bindStringToSQL(message_id, *preparedSQL, 2);
+ bindResult = bindStringToSQL(processed_content, *preparedSQL, 3);
+ } else {
+ preparedSQL = std::make_unique<SQLiteStatementWrapper>(
+ db,
+ updateMessageSearchResultSQL,
+ "Failed to update message search entry.");
+
+ bindStringToSQL(message_id, *preparedSQL, 1);
+ bindStringToSQL(processed_content, *preparedSQL, 2);
+ bindResult = bindStringToSQL(original_message_id, *preparedSQL, 3);
+ }
+
+ if (bindResult != SQLITE_OK) {
+ std::stringstream error_message;
+ error_message << "Failed to bind key to SQL statement. Details: "
+ << sqlite3_errstr(bindResult) << std::endl;
+ throw std::runtime_error(error_message.str());
+ }
+
+ sqlite3_step(*preparedSQL);
+}
+
void SQLiteQueryExecutor::rekeyMessage(std::string from, std::string to) const {
static std::string rekeyMessageSQL =
"UPDATE OR REPLACE messages "

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 1, 3:38 PM (22 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2605369
Default Alt Text
D12778.id42353.diff (3 KB)

Event Timeline