From 78609613bc2f6cd2c7933e4109790530b0e311af Mon Sep 17 00:00:00 2001 From: Phin Wolkwitz Date: Mon, 20 Nov 2023 11:33:12 +0100 Subject: [PATCH] Add notification signal (Z:#23127501) (#3725) * Add and send signal for refund requests * Add and send signal for notifications * Revert changes * Fix typo Co-authored-by: Mira * Document parameters --------- Co-authored-by: Mira --- src/pretix/base/services/notifications.py | 3 +++ src/pretix/base/signals.py | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/src/pretix/base/services/notifications.py b/src/pretix/base/services/notifications.py index b88a518a57..bc34ad3537 100644 --- a/src/pretix/base/services/notifications.py +++ b/src/pretix/base/services/notifications.py @@ -30,6 +30,7 @@ from pretix.base.models import LogEntry, NotificationSetting, User from pretix.base.notifications import Notification, get_all_notification_types from pretix.base.services.mail import mail_send_task from pretix.base.services.tasks import ProfiledTask, TransactionAwareTask +from pretix.base.signals import notification from pretix.celery_app import app from pretix.helpers.urls import build_absolute_uri @@ -90,6 +91,8 @@ def notify(logentry_ids: list): if enabled and um not in notify_specific: send_notification.apply_async(args=(logentry.id, notification_type.action_type, user.pk, method)) + notification.send(logentry.event, logentry_id=logentry.id, notification_type=notification_type.action_type) + @app.task(base=ProfiledTask, acks_late=True, max_retries=9, default_retry_delay=900) def send_notification(logentry_id: int, action_type: str, user_id: int, method: str): diff --git a/src/pretix/base/signals.py b/src/pretix/base/signals.py index 90789ed00b..bb960db395 100644 --- a/src/pretix/base/signals.py +++ b/src/pretix/base/signals.py @@ -279,6 +279,15 @@ however for this signal, the ``sender`` **may also be None** to allow creating t notification settings! """ +notification = EventPluginSignal() +""" +Arguments: ``logentry_id``, ``notification_type`` + +This signal is sent out when a notification is sent. + +As with all event-plugin signals, the ``sender`` keyword argument will contain the event. +""" + register_sales_channels = django.dispatch.Signal() """ This signal is sent out to get all known sales channels types. Receivers should return an