fix: restore push delivery across clients
Some checks failed
Android CI / android (push) Has started running
Android Release / release (push) Has been cancelled
CI / test (push) Has started running

fix: stop suppressing server push notifications based on coarse online presence

fix: rely on FCM delivery for message notifications and remove duplicate Android realtime alerts
This commit is contained in:
2026-04-05 15:25:01 +03:00
parent efd21e6c0f
commit fc98720c4f
2 changed files with 17 additions and 55 deletions

View File

@@ -18,7 +18,6 @@ from app.notifications.schemas import (
PushTokenUpsertRequest,
)
from app.notifications.tasks import send_mention_notification_task, send_push_notification_task
from app.realtime.presence import is_user_online
from app.users.repository import list_users_by_ids
_MENTION_RE = re.compile(r"@([A-Za-z0-9_]{3,50})")
@@ -82,24 +81,23 @@ async def dispatch_message_notifications(db: AsyncSession, message: Message) ->
if await is_chat_muted_for_user(db, chat_id=message.chat_id, user_id=recipient.id):
continue
if not await is_user_online(recipient.id):
payload = {
**base_payload,
"type": "offline_message",
"text_preview": (message.text or "")[:120],
}
await create_notification_log(
db,
user_id=recipient.id,
event_type="offline_message",
payload=json.dumps(payload, ensure_ascii=True),
)
send_push_notification_task.delay(
recipient.id,
f"New message from {sender_name}",
(message.text or "")[:120],
payload,
)
payload = {
**base_payload,
"type": "message",
"text_preview": (message.text or "")[:120],
}
await create_notification_log(
db,
user_id=recipient.id,
event_type="message",
payload=json.dumps(payload, ensure_ascii=True),
)
send_push_notification_task.delay(
recipient.id,
f"New message from {sender_name}",
(message.text or "")[:120],
payload,
)
await db.commit()