memory (sqla): Get original message in thread in history_get:

When using `thread_id` filter, original message could be missing (notably with a reply).
We now include it with `History.uid == filters["thread_id"]`.
This commit is contained in:
Goffi 2026-07-21 19:13:37 +02:00
commit b88d335d92

View file

@ -729,7 +729,13 @@ class Storage:
if "origin_id" in filters:
stmt = stmt.where(History.origin_id == filters["origin_id"])
if "thread_id" in filters:
stmt = stmt.where(Thread.thread_id == filters["thread_id"])
# Include both replies and the parent message (thread_id is the parent uid)
stmt = stmt.where(
or_(
Thread.thread_id == filters["thread_id"],
History.uid == filters["thread_id"],
)
)
if "keyword" in filters:
keyword = filters["keyword"]
# FIXME: "json_each" works with SQLite, but when PostGreSQL support will