notifications/apps/push_notifications/tasks.py
Ali Asadi 8f83a5e84a FEAT(notifications): add optional click_url for notification tap actions
Not every notification is clickable, so click_url is optional end to end
(null/blank on the model, required=False on the serializer). When set, it's
merged into Gotify's own client::notification.click.url extras convention
without disturbing any other extras a producer already sends, so official
Gotify clients can open it on tap. Wired through both message-creation
paths: the single-push REST API and the bulk Excel upload. Also fixes a
pre-existing NameError in the bulk path (json.loads(extras) referenced an
undefined name instead of extras_str).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-08-22 09:36:06 +03:30

22 lines
805 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.get_gotify_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())