Coverage for polar/notifications/tasks/email.py: 44%
16 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 12:42 +0000
1from uuid import UUID
3import structlog
5from polar.email.sender import enqueue_email
6from polar.notifications.service import notifications
7from polar.worker import AsyncSessionMaker, TaskPriority, actor
9log = structlog.get_logger()
12@actor(actor_name="notifications.send", priority=TaskPriority.LOW)
13async def notifications_send(notification_id: UUID) -> None:
14 async with AsyncSessionMaker() as session:
15 notif = await notifications.get(session, notification_id)
16 if not notif:
17 log.warning("notifications.send.not_found")
18 return
20 notification_type = notifications.parse_payload(notif)
21 (subject, body) = notification_type.render()
23 enqueue_email(
24 to_email_addr=notif.user.email, subject=subject, html_content=body
25 )