Validate International phone numbers

- uses new utils methods to validate phone numbers
- defaults to International=True on validation. This ensures the validator works on all numbers
- Then check if the user can send this message to the number internationally if needed.
This commit is contained in:
Martyn Inglis
2017-04-26 15:56:45 +01:00
parent 3d312c7342
commit 2a0f8c8808
12 changed files with 224 additions and 28 deletions

View File

@@ -27,6 +27,7 @@ def post_notification(notification_type):
form = validate(request.get_json(), post_email_request)
else:
form = validate(request.get_json(), post_sms_request)
service = services_dao.dao_fetch_service_by_id(api_user.service_id)
check_service_message_limit(api_user.key_type, service)
form_send_to = form['phone_number'] if notification_type == SMS_TYPE else form['email_address']
@@ -41,7 +42,7 @@ def post_notification(notification_type):
simulated = simulated_recipient(send_to, notification_type)
notification = persist_notification(template_id=template.id,
template_version=template.version,
recipient=send_to,
recipient=form_send_to,
service=service,
personalisation=form.get('personalisation', None),
notification_type=notification_type,