feat: replace email flows with in-app notifications
Add recipient notification detail and filtering, a queued admin composer, and contextual automatic titles. Retire email delivery, obsolete auth routes, newsletter data, and related templates and settings.
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import logging
|
||||
|
||||
from celery import shared_task
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
from apps.notifications.services import RedisNotificationStore
|
||||
from apps.notifications.services import RedisNotificationStore, notify_user
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -12,3 +13,19 @@ def cleanup_notification_retention():
|
||||
removed = RedisNotificationStore.cleanup_expired()
|
||||
logger.info("Cleaned up %s expired notifications", removed)
|
||||
return removed
|
||||
|
||||
|
||||
@shared_task
|
||||
def send_manual_notification(user_ids: list[int], title: str, digest: str, body_markdown: str | None = None):
|
||||
users = get_user_model().objects.filter(pk__in=user_ids, is_active=True, is_deleted=False)
|
||||
sent = 0
|
||||
for user_id in users.values_list("pk", flat=True).iterator():
|
||||
notify_user(user_id, {
|
||||
"type": "manual",
|
||||
"title": title,
|
||||
"message": digest,
|
||||
"body_markdown": body_markdown,
|
||||
"level": "info",
|
||||
})
|
||||
sent += 1
|
||||
return sent
|
||||
|
||||
Reference in New Issue
Block a user