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 <weller@rami.io>

* Document parameters

---------

Co-authored-by: Mira <weller@rami.io>
This commit is contained in:
Phin Wolkwitz
2023-11-20 11:33:12 +01:00
committed by GitHub
parent 78acd8d118
commit 78609613bc
2 changed files with 12 additions and 0 deletions

View File

@@ -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.notifications import Notification, get_all_notification_types
from pretix.base.services.mail import mail_send_task from pretix.base.services.mail import mail_send_task
from pretix.base.services.tasks import ProfiledTask, TransactionAwareTask from pretix.base.services.tasks import ProfiledTask, TransactionAwareTask
from pretix.base.signals import notification
from pretix.celery_app import app from pretix.celery_app import app
from pretix.helpers.urls import build_absolute_uri 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: if enabled and um not in notify_specific:
send_notification.apply_async(args=(logentry.id, notification_type.action_type, user.pk, method)) 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) @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): def send_notification(logentry_id: int, action_type: str, user_id: int, method: str):

View File

@@ -279,6 +279,15 @@ however for this signal, the ``sender`` **may also be None** to allow creating t
notification settings! 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() register_sales_channels = django.dispatch.Signal()
""" """
This signal is sent out to get all known sales channels types. Receivers should return an This signal is sent out to get all known sales channels types. Receivers should return an