notifications/apps/push_notifications/tasks.py
Sayyid Hamid Mahdavi 0901d3e323 bulk push
2025-07-19 15:41:36 +03:30

22 lines
792 B
Python

from main import celery_app
from utils.clients import gotify
@celery_app.task
def send_push_notification(push_message_uuid):
from .models import PushMessage
push_message = PushMessage.objects.get(uuid=push_message_uuid)
gotify.send_notif(token=push_message.push_user.application_token ,
title=push_message.title,
message=push_message.message,
priority=push_message.priority,
extras=push_message.extras)
push_message.state = push_message.StateChoices.DONE
push_message.save()
@celery_app.task
def bulk_push(bulk_push_uuid):
from .models import BulkPushMessage
bulk_push = BulkPushMessage.objects.get(uuid=bulk_push_uuid)
bulk_push.push_to_all(bulk_push.extract_data())