diff --git a/app/celery/tasks.py b/app/celery/tasks.py index 63d4fdc09..0794ad4da 100644 --- a/app/celery/tasks.py +++ b/app/celery/tasks.py @@ -346,9 +346,14 @@ def save_api_email_or_sms(self, encrypted_notification): status=notification["status"], document_download_count=notification["document_download_count"], ) + # Only get here if save to the db was successful (i.e. first time) + provider_task.apply_async([notification["id"]], queue=q) + current_app.logger.debug( + f"{notification['notification_type']} {notification['id']} has been persisted and sent to delivery queue." + ) except IntegrityError: - current_app.logger.info( + current_app.logger.warning( f"{notification['notification_type']} {notification['id']} already exists." ) # If we don't have the return statement here, we will fall through and end @@ -362,10 +367,6 @@ def save_api_email_or_sms(self, encrypted_notification): current_app.logger.exception( f"Max retry failed Failed to persist notification {notification['id']}", ) - provider_task.apply_async([notification["id"]], queue=q) - current_app.logger.debug( - f"{notification['notification_type']} {notification['id']} has been persisted and sent to delivery queue." - ) def handle_exception(task, notification, notification_id, exc):