git » sdk » commit 4c5f33b

Initial sqlite FTS

author Stephen Paul Weber
2026-04-29 18:16:05 UTC
committer Stephen Paul Weber
2026-04-29 18:16:05 UTC
parent 2ff8d5c790a5838c0f853aa37c7959e46712d0da

Initial sqlite FTS

borogove/persistence/Sqlite.hx +11 -0

diff --git a/borogove/persistence/Sqlite.hx b/borogove/persistence/Sqlite.hx
index 2d04722..9dea73c 100644
--- a/borogove/persistence/Sqlite.hx
+++ b/borogove/persistence/Sqlite.hx
@@ -325,6 +325,17 @@ class Sqlite implements Persistence implements KeyValueStore {
 		}, 100);
 	}
 
+	@HaxeCBridge.noemit
+	public function searchMessages(accountId: String, chatId: Null<String>, q: String): Promise<Array<ChatMessage>> {
+		var sql = "SELECT stanza, direction, type, status, status_text, strftime('%FT%H:%M:%fZ', created_at / 1000.0, 'unixepoch') AS timestamp, sender_id, mam_id, mam_by, sort_id, sync_point FROM messages WHERE account_id=? AND stanza LIKE ?";
+		final params = [accountId, "%" + q + "%"];
+		if (chatId != null) {
+			sql += " AND chat_id=?";
+			params.push(chatId);
+		}
+		return db.exec(sql, params).then(result -> hydrateMessages(accountId, result));
+	}
+
 	@HaxeCBridge.noemit
 	public function getChats(accountId: String): Promise<Array<SerializedChat>> {
 		return db.exec(