notification: add notification history
This commit is contained in:
21
core/apps/notifications/tasks/create_notification_history.py
Normal file
21
core/apps/notifications/tasks/create_notification_history.py
Normal file
@@ -0,0 +1,21 @@
|
||||
from celery import shared_task
|
||||
|
||||
from django.shortcuts import get_object_or_404
|
||||
|
||||
from core.apps.notifications.models import NotificationHistory
|
||||
from core.apps.accounts.models import User
|
||||
|
||||
|
||||
@shared_task
|
||||
def create_history(users, title, body, data=None):
|
||||
histories = []
|
||||
for user in users:
|
||||
histories.append(NotificationHistory(
|
||||
title=title,
|
||||
user=user,
|
||||
body=body,
|
||||
data=data,
|
||||
is_read=False
|
||||
))
|
||||
|
||||
NotificationHistory.objects.bulk_create(histories)
|
||||
Reference in New Issue
Block a user