mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
notify-233: delete notifications from notifications table after they are successfully sent
This commit is contained in:
@@ -7,7 +7,10 @@ from app.clients.email.aws_ses import AwsSesClientThrottlingSendRateException
|
||||
from app.clients.sms import SmsClientResponseException
|
||||
from app.config import QueueNames
|
||||
from app.dao import notifications_dao
|
||||
from app.dao.notifications_dao import update_notification_status_by_id
|
||||
from app.dao.notifications_dao import (
|
||||
insert_notification_history_delete_notifications_by_id,
|
||||
update_notification_status_by_id,
|
||||
)
|
||||
from app.delivery import send_to_providers
|
||||
from app.exceptions import NotificationTechnicalFailureException
|
||||
from app.models import NOTIFICATION_TECHNICAL_FAILURE
|
||||
@@ -37,11 +40,13 @@ def deliver_sms(self, notification_id):
|
||||
self.retry(queue=QueueNames.RETRY, countdown=0)
|
||||
else:
|
||||
self.retry(queue=QueueNames.RETRY)
|
||||
insert_notification_history_delete_notifications_by_id(notification_id)
|
||||
except self.MaxRetriesExceededError:
|
||||
message = "RETRY FAILED: Max retries reached. The task send_sms_to_provider failed for notification {}. " \
|
||||
"Notification has been updated to technical-failure".format(notification_id)
|
||||
update_notification_status_by_id(notification_id, NOTIFICATION_TECHNICAL_FAILURE)
|
||||
raise NotificationTechnicalFailureException(message)
|
||||
insert_notification_history_delete_notifications_by_id(notification_id)
|
||||
|
||||
|
||||
@notify_celery.task(bind=True, name="deliver_email", max_retries=48, default_retry_delay=300)
|
||||
|
||||
Reference in New Issue
Block a user