fix: restore push delivery across clients
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:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user