Fix Phase 5 review issues: mark_all_read, datetime, WS payload, logging
Review fixes: - mark_all_read now filters status IN (sent, delivered), preventing pending notifications from being incorrectly marked as read - schedule_notification tool: force UTC on naive datetimes, reject past dates (send immediately instead) - WebSocket notification payload now includes all fields matching NotificationResponse (user_id, channel, status, scheduled_at, etc.) - Centralized _serialize_notification helper in notification_sender - notification_sender: per-notification error handling with rollback - health_review: moved import json to module top level Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Daily job: proactive health review for all users with health data."""
|
||||
import asyncio
|
||||
import json
|
||||
import logging
|
||||
|
||||
from anthropic import AsyncAnthropic
|
||||
@@ -48,7 +49,6 @@ async def _review_user(user: User):
|
||||
messages=[{"role": "user", "content": f"User health profile:\n{memory_text}"}],
|
||||
)
|
||||
|
||||
import json
|
||||
try:
|
||||
text = response.content[0].text.strip()
|
||||
# Extract JSON from response
|
||||
@@ -71,13 +71,8 @@ async def _review_user(user: User):
|
||||
)
|
||||
await db.commit()
|
||||
|
||||
from app.workers.notification_sender import _serialize_notification
|
||||
await manager.send_to_user(user.id, {
|
||||
"type": "new_notification",
|
||||
"notification": {
|
||||
"id": str(notif.id),
|
||||
"title": notif.title,
|
||||
"body": notif.body,
|
||||
"type": notif.type,
|
||||
"created_at": notif.created_at.isoformat(),
|
||||
},
|
||||
"notification": _serialize_notification(notif),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user