Merge pull request #740 from taigaio/issue/4257/Mutiple_configured_webhhoks_trigger_on_the_same_url

Issue 4257: Mutiple configured webhhoks trigger on the same url
remotes/origin/issue/4795/notification_even_they_are_disabled
David Barragán Merino 2016-05-31 11:45:02 +02:00
commit 84e2b90168
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
date = timezone.now()
webhooks_args = []
for webhook in webhooks:
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:
connection.on_commit(lambda: task.delay(*args))
task.delay(*webhook_args)
else:
connection.on_commit(lambda: task(*args))
task(*webhook_args)