mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 09:51:11 -05:00
Rename function in service utils
To reflect the new name of the feature. squash! Rename function in service utils Rename function, variable and argument names in service utils
This commit is contained in:
@@ -78,8 +78,8 @@ def check_template_is_active(template):
|
||||
message="Template has been deleted")
|
||||
|
||||
|
||||
def service_can_send_to_recipient(send_to, key_type, service, allow_whitelisted_recipients=True):
|
||||
if not service_allowed_to_send_to(send_to, service, key_type, allow_whitelisted_recipients):
|
||||
def service_can_send_to_recipient(send_to, key_type, service, allow_guest_list_recipients=True):
|
||||
if not service_allowed_to_send_to(send_to, service, key_type, allow_guest_list_recipients):
|
||||
if key_type == KEY_TYPE_TEAM:
|
||||
message = 'Can’t send to this recipient using a team-only API key'
|
||||
else:
|
||||
@@ -109,11 +109,11 @@ def check_if_service_can_send_files_by_email(service_contact_link, service_id):
|
||||
)
|
||||
|
||||
|
||||
def validate_and_format_recipient(send_to, key_type, service, notification_type, allow_whitelisted_recipients=True):
|
||||
def validate_and_format_recipient(send_to, key_type, service, notification_type, allow_guest_list_recipients=True):
|
||||
if send_to is None:
|
||||
raise BadRequestError(message="Recipient can't be empty")
|
||||
|
||||
service_can_send_to_recipient(send_to, key_type, service, allow_whitelisted_recipients)
|
||||
service_can_send_to_recipient(send_to, key_type, service, allow_guest_list_recipients)
|
||||
|
||||
if notification_type == SMS_TYPE:
|
||||
international_phone_info = check_if_service_can_send_to_number(service, send_to)
|
||||
|
||||
@@ -119,7 +119,7 @@ from app.service.service_senders_schema import (
|
||||
add_service_letter_contact_block_request,
|
||||
add_service_sms_sender_request
|
||||
)
|
||||
from app.service.utils import get_whitelist_objects
|
||||
from app.service.utils import get_guest_list_objects
|
||||
from app.service.sender import send_notification_to_service_users
|
||||
from app.service.send_notification import send_one_off_notification, send_pdf_letter_notification
|
||||
from app.schemas import (
|
||||
@@ -584,7 +584,7 @@ def update_guest_list(service_id):
|
||||
# doesn't commit so if there are any errors, we preserve old values in db
|
||||
dao_remove_service_guest_list(service_id)
|
||||
try:
|
||||
guest_list_objects = get_whitelist_objects(service_id, request.get_json())
|
||||
guest_list_objects = get_guest_list_objects(service_id, request.get_json())
|
||||
except ValueError as e:
|
||||
current_app.logger.exception(e)
|
||||
dao_rollback()
|
||||
|
||||
@@ -73,7 +73,7 @@ def send_one_off_notification(service_id, post_data):
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
service=service,
|
||||
notification_type=template.template_type,
|
||||
allow_whitelisted_recipients=False,
|
||||
allow_guest_list_recipients=False,
|
||||
)
|
||||
|
||||
validate_created_by(service, post_data['created_by'])
|
||||
@@ -147,7 +147,7 @@ def send_pdf_letter_notification(service_id, post_data):
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
service=service,
|
||||
notification_type=LETTER_TYPE,
|
||||
allow_whitelisted_recipients=False,
|
||||
allow_guest_list_recipients=False,
|
||||
)
|
||||
|
||||
template = get_precompiled_letter_template(service.id)
|
||||
|
||||
@@ -14,7 +14,7 @@ def get_recipients_from_request(request_json, key, type):
|
||||
return [(type, recipient) for recipient in request_json.get(key)]
|
||||
|
||||
|
||||
def get_whitelist_objects(service_id, request_json):
|
||||
def get_guest_list_objects(service_id, request_json):
|
||||
return [
|
||||
ServiceWhitelist.from_string(service_id, type, recipient)
|
||||
for type, recipient in (
|
||||
@@ -28,7 +28,7 @@ def get_whitelist_objects(service_id, request_json):
|
||||
]
|
||||
|
||||
|
||||
def service_allowed_to_send_to(recipient, service, key_type, allow_whitelisted_recipients=True):
|
||||
def service_allowed_to_send_to(recipient, service, key_type, allow_guest_list_recipients=True):
|
||||
if key_type == KEY_TYPE_TEST:
|
||||
return True
|
||||
|
||||
@@ -42,9 +42,9 @@ def service_allowed_to_send_to(recipient, service, key_type, allow_whitelisted_r
|
||||
team_members = itertools.chain.from_iterable(
|
||||
[user.mobile_number, user.email_address] for user in service.users
|
||||
)
|
||||
whitelist_members = [
|
||||
guest_list_members = [
|
||||
member.recipient for member in service.whitelist
|
||||
if allow_whitelisted_recipients
|
||||
if allow_guest_list_recipients
|
||||
]
|
||||
|
||||
if (
|
||||
@@ -55,6 +55,6 @@ def service_allowed_to_send_to(recipient, service, key_type, allow_whitelisted_r
|
||||
recipient,
|
||||
itertools.chain(
|
||||
team_members,
|
||||
whitelist_members
|
||||
guest_list_members
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user