mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Serialise service, API keys and permissions
By serialising these straight away we can: - not go back to the database later, potentially closing the connection sooner - potentially cache the serialised data, meaning we don’t touch the database at all
This commit is contained in:
@@ -123,7 +123,6 @@ def persist_notification(
|
||||
template_version=template_version,
|
||||
to=recipient,
|
||||
service_id=service.id,
|
||||
service=service,
|
||||
personalisation=personalisation,
|
||||
notification_type=notification_type,
|
||||
api_key_id=api_key_id,
|
||||
|
||||
@@ -90,7 +90,7 @@ def service_can_send_to_recipient(send_to, key_type, service, allow_whitelisted_
|
||||
|
||||
|
||||
def service_has_permission(notify_type, permissions):
|
||||
return notify_type in [p.permission for p in permissions]
|
||||
return notify_type in permissions
|
||||
|
||||
|
||||
def check_service_has_permission(notify_type, permissions):
|
||||
@@ -137,7 +137,7 @@ def check_if_service_can_send_to_number(service, number):
|
||||
if (
|
||||
# if number is international and not a crown dependency
|
||||
international_phone_info.international and not international_phone_info.crown_dependency
|
||||
) and INTERNATIONAL_SMS_TYPE not in [p.permission for p in service.permissions]:
|
||||
) and INTERNATIONAL_SMS_TYPE not in service.permissions:
|
||||
raise BadRequestError(message="Cannot send to international mobile numbers")
|
||||
else:
|
||||
return international_phone_info
|
||||
|
||||
Reference in New Issue
Block a user