Merge pull request #2916 from alphagov/prevent-race-condition-sms-status

Do not update notification to sending if the status is already final
This commit is contained in:
Pea M. Tyczynska
2020-07-06 13:16:36 +01:00
committed by GitHub
2 changed files with 19 additions and 3 deletions

View File

@@ -28,7 +28,8 @@ from app.models import (
EMAIL_TYPE,
NOTIFICATION_TECHNICAL_FAILURE,
NOTIFICATION_SENT,
NOTIFICATION_SENDING
NOTIFICATION_SENDING,
NOTIFICATION_STATUS_TYPES_COMPLETED
)
@@ -125,7 +126,8 @@ def send_email_to_provider(notification):
def update_notification_to_sending(notification, provider):
notification.sent_at = datetime.utcnow()
notification.sent_by = provider.get_name()
notification.status = NOTIFICATION_SENT if notification.international else NOTIFICATION_SENDING
if notification.status not in NOTIFICATION_STATUS_TYPES_COMPLETED:
notification.status = NOTIFICATION_SENT if notification.international else NOTIFICATION_SENDING
dao_update_notification(notification)