mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-25 18:39:11 -04:00
Merge pull request #318 from alphagov/tech-failures
New notification status types
This commit is contained in:
@@ -86,6 +86,9 @@ def delete_failed_notifications():
|
||||
try:
|
||||
start = datetime.utcnow()
|
||||
deleted = delete_notifications_created_more_than_a_week_ago('failed')
|
||||
deleted += delete_notifications_created_more_than_a_week_ago('technical-failure')
|
||||
deleted += delete_notifications_created_more_than_a_week_ago('temporary-failure')
|
||||
deleted += delete_notifications_created_more_than_a_week_ago('permanent-failure')
|
||||
current_app.logger.info(
|
||||
"Delete job started {} finished {} deleted {} failed notifications".format(
|
||||
start,
|
||||
@@ -268,7 +271,7 @@ def send_sms(service_id, notification_id, encrypted_notification, created_at):
|
||||
"SMS notification {} failed".format(notification_id)
|
||||
)
|
||||
current_app.logger.exception(e)
|
||||
notification_db_object.status = 'failed'
|
||||
notification_db_object.status = 'technical-failure'
|
||||
|
||||
dao_update_notification(notification_db_object)
|
||||
current_app.logger.info(
|
||||
@@ -338,7 +341,7 @@ def send_email(service_id, notification_id, from_address, encrypted_notification
|
||||
|
||||
except EmailClientException as e:
|
||||
current_app.logger.exception(e)
|
||||
notification_db_object.status = 'failed'
|
||||
notification_db_object.status = 'technical-failure'
|
||||
dao_update_notification(notification_db_object)
|
||||
|
||||
current_app.logger.info(
|
||||
|
||||
@@ -305,7 +305,8 @@ class VerifyCode(db.Model):
|
||||
return check_hash(cde, self._code)
|
||||
|
||||
|
||||
NOTIFICATION_STATUS_TYPES = ['sending', 'delivered', 'failed']
|
||||
NOTIFICATION_STATUS_TYPES = ['sending', 'delivered', 'failed',
|
||||
'technical-failure', 'temporary-failure', 'permanent-failure']
|
||||
|
||||
|
||||
class Notification(db.Model):
|
||||
@@ -340,7 +341,7 @@ class Notification(db.Model):
|
||||
nullable=True,
|
||||
onupdate=datetime.datetime.utcnow)
|
||||
status = db.Column(
|
||||
db.Enum(*NOTIFICATION_STATUS_TYPES, name='notification_status_types'), nullable=False, default='sending')
|
||||
db.Enum(*NOTIFICATION_STATUS_TYPES, name='notification_status_type'), nullable=False, default='sending')
|
||||
reference = db.Column(db.String, nullable=True, index=True)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user