feat(telegram,core): master topic instead of general in private chats

This commit is contained in:
hh
2026-08-28 18:12:58 +02:00
parent 45a5eb4a94
commit b0f280b3ca
3 changed files with 93 additions and 18 deletions
+22
View File
@@ -345,6 +345,28 @@ class Conversations:
)
return result.first()
async def last_binding(
self, *, frontend: str, kind: str
) -> ConversationBinding | None:
"""The window ``frontend`` last used for a conversation of ``kind``.
A frontend whose window for the master outlives the master itself
(the Telegram General topic) finds it here after a rotation.
"""
async with self._db.session() as session:
result = await session.exec(
select(ConversationBinding)
.join(
Conversation,
col(Conversation.id) == col(ConversationBinding.conversation_id),
)
.where(
ConversationBinding.frontend == frontend, Conversation.kind == kind
)
.order_by(col(ConversationBinding.id).desc())
)
return result.first()
async def set_flags(
self, conv: Conversation, flags: dict[str, Any]
) -> Conversation: