Badge-System: personal/general Split, Punkte ohne Zahl, SW by-v328
This commit is contained in:
parent
0a3ad2207e
commit
fc7d743153
4 changed files with 35 additions and 13 deletions
|
|
@ -40,6 +40,35 @@ async def unread_count(user=Depends(get_current_user)):
|
|||
return {"count": row[0]}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# GET /api/notifications/badge — Dot-Indikatoren für Header
|
||||
# personal: Chat, Freunde, Trainer, Sitting, Gesundheit, Meilensteine
|
||||
# general: Gassi-Treffen, Giftköder, Verlorene Hunde, Wetter
|
||||
# ------------------------------------------------------------------
|
||||
_PERSONAL = {
|
||||
'chat_message', 'friend_request', 'weekly_praise',
|
||||
'health_reminder', 'milestone',
|
||||
'sitting_request', 'sitting_confirmed', 'sitting_cancelled',
|
||||
}
|
||||
_GENERAL = {
|
||||
'walk_invite', 'lost_dog_alert', 'poison_alert',
|
||||
'weather_heat', 'weather_thunder',
|
||||
}
|
||||
|
||||
@router.get("/badge")
|
||||
async def badge_status(user=Depends(get_current_user)):
|
||||
with db() as conn:
|
||||
rows = conn.execute(
|
||||
"SELECT DISTINCT type FROM notifications WHERE user_id=? AND read_at IS NULL",
|
||||
(user["id"],),
|
||||
).fetchall()
|
||||
types = {r["type"] for r in rows}
|
||||
return {
|
||||
"personal": bool(types & _PERSONAL),
|
||||
"general": bool(types & _GENERAL),
|
||||
}
|
||||
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# PATCH /api/notifications/read-all — alle als gelesen markieren
|
||||
# ------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue