Add support for bulk-webhooks

This commit is contained in:
Raphael Michel
2020-11-06 11:46:06 +01:00
parent a7565342c0
commit eeb3c1a960
4 changed files with 99 additions and 61 deletions

View File

@@ -49,9 +49,7 @@ class LoggingMixin:
:param user: The user performing the action (optional)
"""
from pretix.api.models import OAuthAccessToken, OAuthApplication
from pretix.api.webhooks import get_all_webhook_events, notify_webhooks
from ..notifications import get_all_notification_types
from pretix.api.webhooks import notify_webhooks
from ..services.notifications import notify
from .devices import Device
from .event import Event
@@ -93,21 +91,11 @@ class LoggingMixin:
if save:
logentry.save()
no_types = get_all_notification_types()
wh_types = get_all_webhook_events()
no_type = None
wh_type = None
typepath = logentry.action_type
while (not no_type or not wh_types) and '.' in typepath:
wh_type = wh_type or wh_types.get(typepath + ('.*' if typepath != logentry.action_type else ''))
no_type = no_type or no_types.get(typepath + ('.*' if typepath != logentry.action_type else ''))
typepath = typepath.rsplit('.', 1)[0]
if no_type:
if logentry.notification_type:
notify.apply_async(args=(logentry.pk,))
if wh_type:
if logentry.webhook_type:
notify_webhooks.apply_async(args=(logentry.pk,))
return logentry