forked from CGM_Public/pretix_original
Webhooks: Fix retry logic (Z#23197527) (#5250)
* Webhooks: Fix retry logic (Z#23197527) * Add no-op migration
This commit is contained in:
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.2.17 on 2025-06-24 14:13
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("pretixapi", "0012_oauthapplication_post_logout_redirect_uris"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="webhookcallretry",
|
||||||
|
name="retry_not_before",
|
||||||
|
field=models.DateTimeField(),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -157,7 +157,7 @@ class WebHookCallRetry(models.Model):
|
|||||||
id = models.BigAutoField(primary_key=True)
|
id = models.BigAutoField(primary_key=True)
|
||||||
webhook = models.ForeignKey('WebHook', on_delete=models.CASCADE, related_name='retries')
|
webhook = models.ForeignKey('WebHook', on_delete=models.CASCADE, related_name='retries')
|
||||||
logentry = models.ForeignKey('pretixbase.LogEntry', on_delete=models.CASCADE, related_name='webhook_retries')
|
logentry = models.ForeignKey('pretixbase.LogEntry', on_delete=models.CASCADE, related_name='webhook_retries')
|
||||||
retry_not_before = models.DateTimeField(auto_now_add=True)
|
retry_not_before = models.DateTimeField()
|
||||||
retry_count = models.PositiveIntegerField(default=0)
|
retry_count = models.PositiveIntegerField(default=0)
|
||||||
action_type = models.CharField(max_length=255)
|
action_type = models.CharField(max_length=255)
|
||||||
|
|
||||||
|
|||||||
@@ -527,8 +527,10 @@ def send_webhook(self, logentry_id: int, action_type: str, webhook_id: int, retr
|
|||||||
if retry_count >= len(retry_intervals):
|
if retry_count >= len(retry_intervals):
|
||||||
return 'retry-given-up'
|
return 'retry-given-up'
|
||||||
elif retry_intervals[retry_count] < retry_celery_cutoff:
|
elif retry_intervals[retry_count] < retry_celery_cutoff:
|
||||||
send_webhook.apply_async(args=(logentry_id, action_type, webhook_id, retry_count + 1),
|
send_webhook.apply_async(
|
||||||
countdown=retry_intervals[retry_count])
|
args=(logentry_id, action_type, webhook_id, retry_count + 1),
|
||||||
|
countdown=retry_intervals[retry_count]
|
||||||
|
)
|
||||||
return 'retry-via-celery'
|
return 'retry-via-celery'
|
||||||
else:
|
else:
|
||||||
webhook.retries.update_or_create(
|
webhook.retries.update_or_create(
|
||||||
@@ -555,7 +557,10 @@ def send_webhook(self, logentry_id: int, action_type: str, webhook_id: int, retr
|
|||||||
if retry_count >= len(retry_intervals):
|
if retry_count >= len(retry_intervals):
|
||||||
return 'retry-given-up'
|
return 'retry-given-up'
|
||||||
elif retry_intervals[retry_count] < retry_celery_cutoff:
|
elif retry_intervals[retry_count] < retry_celery_cutoff:
|
||||||
send_webhook.apply_async(args=(logentry_id, action_type, webhook_id, retry_count + 1))
|
send_webhook.apply_async(
|
||||||
|
args=(logentry_id, action_type, webhook_id, retry_count + 1),
|
||||||
|
countdown=retry_intervals[retry_count]
|
||||||
|
)
|
||||||
return 'retry-via-celery'
|
return 'retry-via-celery'
|
||||||
else:
|
else:
|
||||||
webhook.retries.update_or_create(
|
webhook.retries.update_or_create(
|
||||||
|
|||||||
Reference in New Issue
Block a user