-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix fake callback #2178
Fix fake callback #2178
Conversation
"Phone carrier is currently unreachable/unavailable", notification_id, destination=to, timestamp=timestamp | ||
) | ||
else: | ||
return pinpoint_delivered_callback(notification_id, destination=to, timestamp=timestamp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like only the last line is different, could we merge the logic on top into one common function, which would differ on that last function call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 instead of
def aws_pinpoint_callback(notification_id, to):
now = datetime.now()
timestamp = now.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
if to.strip().endswith(perm_fail):
return pinpoint_failed_callback(
"Phone is currently unreachable/unavailable", notification_id, destination=to, timestamp=timestamp
)
elif to.strip().endswith(temp_fail):
return pinpoint_failed_callback(
"Phone carrier is currently unreachable/unavailable", notification_id, destination=to, timestamp=timestamp
)
else:
return pinpoint_delivered_callback(notification_id, destination=to, timestamp=timestamp)
What about
def aws_pinpoint_callback(notification_id, to):
now = datetime.now()
timestamp = now.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3]
using_test_perm_fail_number = to.strip().endswith(perm_fail)
using_test_temp_fail_number = to.strip().endswith(temp_fail)
if using_test_perm_fail_number or using_test_temp_fail_number:
return pinpoint_failed_callback(
"Phone is currently unreachable/unavailable" if using_test_perm_fail_number else "Phone carrier is currently unreachable/unavailable",
notification_id,
destination=to,
timestamp=timestamp
)
else:
return pinpoint_delivered_callback(notification_id, destination=to, timestamp=timestamp)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's ship it as is for now. I think what I was thinking of is a proper abstraction that would send the callback based on the implementation, which would simplify the call sites code, but would likely repeat in the abstractions (potentially objects and with some template patterns).
mock_task.apply_async.assert_called_once_with(ANY, queue=QueueNames.RESEARCH_MODE) | ||
message_celery = mock_task.apply_async.call_args[0][0][0] | ||
pinpoint_callback_args.update({"reference": some_ref, "destination": phone_number, "timestamp": timestamp}) | ||
assert message_celery == pinpoint_callback(**pinpoint_callback_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳
e8ad615
to
0973784
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sir
Summary | Résumé
The
INTERNAL_TEST_NUMBER
(which is used by the smoke test) was causing an error after we switched on Pinpoint: the fake callback was being processed by the sns callback task rather than the pinpoint callback task. This PR ensures that the correct task (ie based on the provider being used) is called.Related Issues | Cartes liées
Test instructions | Instructions pour tester la modification
To test locally:
Set env vars (from staging):
Send an SMS to 16135550123. It should immediately register as sent. and there should be no celery errors.
Release Instructions | Instructions pour le déploiement
None.
Reviewer checklist | Liste de vérification du réviseur