fix: OUT messages no longer create unread status + handle Telegram read receipts

Only inbound (IN) messages determine hasUnread in getContacts(). Telegram
read_business_message events are now parsed and processed to auto-mark
contacts as read for the entire team.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Ruslan Bakiev
2026-02-25 14:53:55 +07:00
parent 6291797bb6
commit 0f87586e81
3 changed files with 73 additions and 2 deletions

View File

@@ -426,7 +426,7 @@ async function getContacts(auth: AuthContext | null) {
include: {
note: { select: { content: true } },
messages: {
...(messageWhere ? { where: messageWhere } : {}),
where: { direction: "IN", ...(messageWhere ?? {}) },
select: { content: true, channel: true, occurredAt: true },
orderBy: { occurredAt: "desc" as const },
take: 1,