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:
2026-03-19 14:14:08 +03:00
parent ada7e82961
commit 04e3ae8319
4 changed files with 44 additions and 29 deletions

View File

@@ -76,6 +76,7 @@ async def mark_all_read(db: AsyncSession, user_id: uuid.UUID) -> int:
.where(
Notification.user_id == user_id,
Notification.read_at.is_(None),
Notification.status.in_(["sent", "delivered"]),
)
.values(status="read", read_at=datetime.now(timezone.utc))
)