mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Use the same validation in the endpoint and the task to validate the phone number is ok to send to.
Format the phone number before sending it to the sms provider.
This commit is contained in:
15
app/validation.py
Normal file
15
app/validation.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from utils.recipients import format_phone_number, validate_phone_number
|
||||
|
||||
|
||||
def allowed_send_to_number(service, to):
|
||||
if service.restricted and format_phone_number(validate_phone_number(to)) not in [
|
||||
format_phone_number(validate_phone_number(user.mobile_number)) for user in service.users
|
||||
]:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def allowed_send_to_email(service, to):
|
||||
if service.restricted and to not in [user.email_address for user in service.users]:
|
||||
return False
|
||||
return True
|
||||
Reference in New Issue
Block a user