Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33503847
D12844.1769059354.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D12844.1769059354.diff
View Options
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
@@ -2556,8 +2556,51 @@
std::string threadID,
std::optional<std::string> timestampCursor,
std::optional<std::string> messageIDCursor) const {
+ std::stringstream searchMessagesSQL;
+ searchMessagesSQL
+ << "SELECT "
+ " m.id, m.local_id, m.thread, m.user, m.type, m.future_type, "
+ " m.content, m.time, media.id, media.container, media.thread, "
+ " media.uri, media.type, media.extras "
+ "FROM message_search AS s "
+ "LEFT JOIN messages AS m "
+ " ON m.id = s.original_message_id "
+ "LEFT JOIN media "
+ " ON m.id = media.container "
+ "LEFT JOIN messages AS m2 "
+ " ON m2.target_message = m.id "
+ " AND m2.type = ? AND m2.thread = ? "
+ "WHERE s.processed_content MATCH ? "
+ " AND (m.thread = ? OR m2.id IS NOT NULL) ";
+
+ bool usingCursor = timestampCursor.has_value() && messageIDCursor.has_value();
+
+ if (usingCursor) {
+ searchMessagesSQL << " AND (m.time < ? OR (m.time = ? AND m.id < ?)) ";
+ }
+ searchMessagesSQL << "ORDER BY m.time DESC, m.id DESC "
+ << "LIMIT 20;";
- return std::vector<MessageEntity>{};
+ comm::SQLiteStatementWrapper preparedSQL(
+ SQLiteQueryExecutor::getConnection(),
+ searchMessagesSQL.str(),
+ "Failed to get message search results");
+
+ auto SIDEBAR_SOURCE_TYPE = 17;
+
+ bindIntToSQL(SIDEBAR_SOURCE_TYPE, preparedSQL, 1);
+ bindStringToSQL(threadID.c_str(), preparedSQL, 2);
+ bindStringToSQL(query.c_str(), preparedSQL, 3);
+ bindStringToSQL(threadID.c_str(), preparedSQL, 4);
+
+ if (usingCursor) {
+ int timestamp = std::stoll(timestampCursor.value());
+ bindIntToSQL(timestamp, preparedSQL, 5);
+ bindIntToSQL(timestamp, preparedSQL, 6);
+ bindStringToSQL(messageIDCursor.value(), preparedSQL, 7);
+ }
+
+ return this->processMessagesResults(preparedSQL);
}
#ifdef EMSCRIPTEN
diff --git a/web/shared-worker/_generated/comm_query_executor.wasm b/web/shared-worker/_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
Thu, Jan 22, 5:22 AM (2 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5974337
Default Alt Text
D12844.1769059354.diff (2 KB)
Attached To
Mode
D12844: [SQLite] implement query for searching messages
Attached
Detach File
Event Timeline
Log In to Comment