mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-10 10:03:38 -04:00
Normalize outbound SMS number for job notifications
Replaces 0 with 44 in UK SMS sender number to make it possible to respond to the SMS from an international number.
This commit is contained in:
@@ -14,6 +14,7 @@ from sqlalchemy import UniqueConstraint, CheckConstraint
|
|||||||
from notifications_utils.recipients import (
|
from notifications_utils.recipients import (
|
||||||
validate_email_address,
|
validate_email_address,
|
||||||
validate_phone_number,
|
validate_phone_number,
|
||||||
|
try_validate_and_format_phone_number,
|
||||||
InvalidPhoneError,
|
InvalidPhoneError,
|
||||||
InvalidEmailError
|
InvalidEmailError
|
||||||
)
|
)
|
||||||
@@ -636,7 +637,7 @@ class TemplateBase(db.Model):
|
|||||||
elif self.template_type == EMAIL_TYPE:
|
elif self.template_type == EMAIL_TYPE:
|
||||||
return self.service.get_default_reply_to_email_address()
|
return self.service.get_default_reply_to_email_address()
|
||||||
elif self.template_type == SMS_TYPE:
|
elif self.template_type == SMS_TYPE:
|
||||||
return self.service.get_default_sms_sender()
|
return try_validate_and_format_phone_number(self.service.get_default_sms_sender())
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -1081,6 +1081,25 @@ def test_save_letter_uses_template_reply_to_text(mocker, notify_db_session):
|
|||||||
assert notification_db.reply_to_text == "Template address contact"
|
assert notification_db.reply_to_text == "Template address contact"
|
||||||
|
|
||||||
|
|
||||||
|
def test_save_sms_uses_sms_sender_reply_to_text(mocker, notify_db_session):
|
||||||
|
service = create_service_with_defined_sms_sender(sms_sender_value='07123123123')
|
||||||
|
template = create_template(service=service)
|
||||||
|
|
||||||
|
notification = _notification_json(template, to="07700 900205")
|
||||||
|
mocker.patch('app.celery.provider_tasks.deliver_sms.apply_async')
|
||||||
|
|
||||||
|
notification_id = uuid.uuid4()
|
||||||
|
save_sms(
|
||||||
|
service.id,
|
||||||
|
notification_id,
|
||||||
|
encryption.encrypt(notification),
|
||||||
|
key_type=KEY_TYPE_TEST
|
||||||
|
)
|
||||||
|
|
||||||
|
persisted_notification = Notification.query.one()
|
||||||
|
assert persisted_notification.reply_to_text == '447123123123'
|
||||||
|
|
||||||
|
|
||||||
def test_save_letter_calls_update_noti_to_sent_task_with_letters_as_pdf_permission_in_research_mode(
|
def test_save_letter_calls_update_noti_to_sent_task_with_letters_as_pdf_permission_in_research_mode(
|
||||||
mocker, notify_db_session, sample_letter_job):
|
mocker, notify_db_session, sample_letter_job):
|
||||||
sample_letter_job.service.research_mode = True
|
sample_letter_job.service.research_mode = True
|
||||||
|
|||||||
Reference in New Issue
Block a user