fix: read receipts (single/double check), push notifications for all users

- Track when others read messages via messages_read WS event
- Show Check (single) for sent, CheckCheck (double) only when read
- Send push to all recipients, SW suppresses if app is focused

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ai
2026-05-22 13:47:38 +03:00
parent 86073c0549
commit 20daa2ca2f
6 changed files with 31 additions and 16 deletions

View File

@@ -27,13 +27,10 @@ async function getChatMemberIds(chatId: string): Promise<string[]> {
}
async function sendPushToOfflineUsers(uids: string[], payload: object) {
const online = new Set(connections.keys());
const offline = uids.filter(id => !online.has(id));
if (offline.length === 0) return;
// Send to all — SW on client side will suppress if app is in foreground
const { rows } = await pool.query(
'SELECT endpoint, auth_key, p256dh FROM push_subscriptions WHERE user_id = ANY($1)',
[offline]
[uids]
);
const body = JSON.stringify(payload);