[Backport] Issue 4257: Mutiple configured webhhoks trigger on the same url

remotes/origin/issue/4795/notification_even_they_are_disabled
Alejandro Alonso 2016-05-31 08:58:42 +02:00 committed by David Barragán Merino
parent 998022c3ba
commit fc20d6c8f5
1 changed files with 10 additions and 2 deletions

View File

@ -67,10 +67,18 @@ def on_new_history_entry(sender, instance, created, **kwargs):
by = instance.owner by = instance.owner
date = timezone.now() date = timezone.now()
webhooks_args = []
for webhook in webhooks: for webhook in webhooks:
args = [webhook["id"], webhook["url"], webhook["key"], by, date, obj] + extra_args args = [webhook["id"], webhook["url"], webhook["key"], by, date, obj] + extra_args
webhooks_args.append(args)
connection.on_commit(lambda: _execute_task(task, webhooks_args))
def _execute_task(task, webhooks_args):
for webhook_args in webhooks_args:
if settings.CELERY_ENABLED: if settings.CELERY_ENABLED:
connection.on_commit(lambda: task.delay(*args)) task.delay(*webhook_args)
else: else:
connection.on_commit(lambda: task(*args)) task(*webhook_args)