Skip to content

Commit

Permalink
#1449 - BUG: Pinpoint Successful Status Sent vs Delivered (#1463)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanParish authored Sep 26, 2023
1 parent 183ea58 commit 106a5fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
15 changes: 10 additions & 5 deletions app/celery/process_pinpoint_receipt_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@
NOTIFICATION_SENDING,
NOTIFICATION_TEMPORARY_FAILURE,
NOTIFICATION_PERMANENT_FAILURE,
NOTIFICATION_SENT, Notification, NOTIFICATION_PREFERENCES_DECLINED
NOTIFICATION_PREFERENCES_DECLINED,
Notification
)
from app.celery.service_callback_tasks import check_and_queue_callback_task

FINAL_STATUS_STATES = [NOTIFICATION_DELIVERED, NOTIFICATION_PERMANENT_FAILURE, NOTIFICATION_TECHNICAL_FAILURE,
NOTIFICATION_PREFERENCES_DECLINED]
FINAL_STATUS_STATES = [
NOTIFICATION_DELIVERED,
NOTIFICATION_PERMANENT_FAILURE,
NOTIFICATION_TECHNICAL_FAILURE,
NOTIFICATION_PREFERENCES_DECLINED
]

_record_status_status_mapping = {
'SUCCESSFUL': NOTIFICATION_SENT,
'SUCCESSFUL': NOTIFICATION_DELIVERED,
'DELIVERED': NOTIFICATION_DELIVERED,
'PENDING': NOTIFICATION_SENDING,
'INVALID': NOTIFICATION_TECHNICAL_FAILURE,
Expand Down Expand Up @@ -136,7 +141,7 @@ def process_pinpoint_results(self, response):
def get_notification_status(event_type: str, record_status: str, reference: str) -> str:
if event_type == '_SMS.OPTOUT':
current_app.logger.info("event type is OPTOUT for notification with reference %s", reference)
statsd_client.incr(f"callback.pinpoint.optout")
statsd_client.incr("callback.pinpoint.optout")
notification_status = NOTIFICATION_PERMANENT_FAILURE
else:
notification_status = _map_record_status_to_notification_status(record_status)
Expand Down
4 changes: 2 additions & 2 deletions app/notifications/aws_sns_status_callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from app import statsd_client
from app.schema_validation import validate
from app.schema_validation.definitions import uuid
from app.models import NOTIFICATION_FAILED, NOTIFICATION_SENT
from app.models import NOTIFICATION_FAILED, NOTIFICATION_DELIVERED
from app.dao.notifications_dao import dao_get_notification_by_reference, _update_notification_status
from app.notifications.process_client_response import process_service_callback

Expand All @@ -14,7 +14,7 @@
SNS_STATUS_TYPES = [SNS_STATUS_SUCCESS, SNS_STATUS_FAILURE]

aws_sns_status_map = {
SNS_STATUS_SUCCESS: NOTIFICATION_SENT,
SNS_STATUS_SUCCESS: NOTIFICATION_DELIVERED,
SNS_STATUS_FAILURE: NOTIFICATION_FAILED
}

Expand Down
3 changes: 1 addition & 2 deletions tests/app/celery/test_process_pinpoint_receipt_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
NOTIFICATION_TECHNICAL_FAILURE,
NOTIFICATION_TEMPORARY_FAILURE,
NOTIFICATION_PERMANENT_FAILURE,
NOTIFICATION_SENT
)
from tests.app.db import create_notification

Expand All @@ -35,7 +34,7 @@ def test_passes_if_toggle_disabled(mocker, notify_db_session):


@pytest.mark.parametrize('event_type, record_status, expected_notification_status', [
('_SMS.BUFFERED', 'SUCCESSFUL', NOTIFICATION_SENT),
('_SMS.BUFFERED', 'SUCCESSFUL', NOTIFICATION_DELIVERED),
('_SMS.SUCCESS', 'DELIVERED', NOTIFICATION_DELIVERED),
('_SMS.FAILURE', 'INVALID', NOTIFICATION_TECHNICAL_FAILURE),
('_SMS.FAILURE', 'UNREACHABLE', NOTIFICATION_TEMPORARY_FAILURE),
Expand Down

0 comments on commit 106a5fb

Please sign in to comment.