Push payload carries the recipient's unread notification count

The notification funnel computes count_unread_groups right after the
in-app insert and adds it to the shared push payload as unread, only
when a push is actually sent. Providers decide how to present it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-15 04:03:10 +01:00
co-authored by Claude Sonnet 5.5
parent 8b45a515f2
commit 376c6ba99d
2 changed files with 8 additions and 4 deletions
+7 -3
View File
@@ -10,6 +10,7 @@ from devplacepy.database import (
notification_group_key,
NOTIFICATION_GROUP_KEYS,
get_silenced_uids,
count_unread_groups,
)
from devplacepy.services.background import background
from devplacepy.utils.text import generate_uid, extract_mentions
@@ -23,7 +24,7 @@ DEFAULT_PUSH_URL = "/notifications"
_push_tasks: set[asyncio.Task] = set()
async def _safe_notify(user_uid: str, payload: dict[str, str]) -> None:
async def _safe_notify(user_uid: str, payload: dict[str, str | int]) -> None:
from devplacepy import push
try:
@@ -32,12 +33,15 @@ async def _safe_notify(user_uid: str, payload: dict[str, str]) -> None:
logger.warning("Push delivery failed for %s: %s", user_uid, e)
def _schedule_push(user_uid: str, message: str, target_url: str | None) -> None:
def _schedule_push(
user_uid: str, message: str, target_url: str | None, unread: int
) -> None:
payload = {
"title": "DevPlace",
"message": message,
"icon": PUSH_ICON,
"url": target_url or DEFAULT_PUSH_URL,
"unread": unread,
}
try:
loop = asyncio.get_running_loop()
@@ -134,7 +138,7 @@ def _deliver_notification(
)
clear_unread_cache(user_uid)
if push:
_schedule_push(user_uid, message, target_url)
_schedule_push(user_uid, message, target_url, count_unread_groups(user_uid))
if telegram:
_schedule_telegram(user_uid, message)
from devplacepy.services.audit import record as audit
+1 -1
View File
@@ -1,6 +1,6 @@
[project]
name = "devplacepy"
version = "1.1.28"
version = "1.1.29"
description = "DevPlace - The Developer Social Network"
requires-python = ">=3.12"
dependencies = [