mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 07:21:13 -05:00
@@ -73,8 +73,9 @@ from app.dao.services_dao import (
|
||||
)
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
from app.dao.users_dao import get_user_by_id
|
||||
from app.enums import KeyType
|
||||
from app.errors import InvalidRequest, register_errors
|
||||
from app.models import KEY_TYPE_NORMAL, EmailBranding, Permission, Service
|
||||
from app.models import EmailBranding, Permission, Service
|
||||
from app.notifications.process_notifications import (
|
||||
persist_notification,
|
||||
send_notification_to_queue,
|
||||
@@ -782,7 +783,7 @@ def verify_reply_to_email_address(service_id):
|
||||
personalisation="",
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
key_type=KeyType.NORMAL,
|
||||
reply_to_text=notify_service.get_default_reply_to_email_address(),
|
||||
)
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ from app.dao.service_sms_sender_dao import dao_get_service_sms_senders_by_id
|
||||
from app.dao.services_dao import dao_fetch_service_by_id
|
||||
from app.dao.templates_dao import dao_get_template_by_id_and_service_id
|
||||
from app.dao.users_dao import get_user_by_id
|
||||
from app.enums import NotificationType
|
||||
from app.models import KEY_TYPE_NORMAL, PRIORITY
|
||||
from app.enums import NotificationType, KeyType
|
||||
from app.models import PRIORITY
|
||||
from app.notifications.process_notifications import (
|
||||
persist_notification,
|
||||
send_notification_to_queue,
|
||||
@@ -46,11 +46,11 @@ def send_one_off_notification(service_id, post_data):
|
||||
|
||||
validate_template(template.id, personalisation, service, template.template_type)
|
||||
|
||||
check_service_over_total_message_limit(KEY_TYPE_NORMAL, service)
|
||||
check_service_over_total_message_limit(KeyType.NORMAL, service)
|
||||
|
||||
validate_and_format_recipient(
|
||||
send_to=post_data["to"],
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
key_type=KeyType.NORMAL,
|
||||
service=service,
|
||||
notification_type=template.template_type,
|
||||
allow_guest_list_recipients=False,
|
||||
@@ -74,7 +74,7 @@ def send_one_off_notification(service_id, post_data):
|
||||
personalisation=personalisation,
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
key_type=KeyType.NORMAL,
|
||||
created_by_id=post_data["created_by"],
|
||||
reply_to_text=reply_to,
|
||||
reference=create_one_off_reference(template.template_type),
|
||||
|
||||
@@ -6,8 +6,7 @@ from app.dao.services_dao import (
|
||||
dao_fetch_service_by_id,
|
||||
)
|
||||
from app.dao.templates_dao import dao_get_template_by_id
|
||||
from app.enums import TemplateType
|
||||
from app.models import KEY_TYPE_NORMAL
|
||||
from app.enums import TemplateType, KeyType
|
||||
from app.notifications.process_notifications import (
|
||||
persist_notification,
|
||||
send_notification_to_queue,
|
||||
@@ -36,7 +35,7 @@ def send_notification_to_service_users(
|
||||
personalisation=personalisation,
|
||||
notification_type=template.template_type,
|
||||
api_key_id=None,
|
||||
key_type=KEY_TYPE_NORMAL,
|
||||
key_type=KeyType.NORMAL,
|
||||
reply_to_text=notify_service.get_default_reply_to_email_address(),
|
||||
)
|
||||
send_notification_to_queue(notification, queue=QueueNames.NOTIFY)
|
||||
|
||||
@@ -3,8 +3,8 @@ import itertools
|
||||
from notifications_utils.recipients import allowed_to_send_to
|
||||
|
||||
from app.dao.services_dao import dao_fetch_service_by_id
|
||||
from app.enums import RecipientType
|
||||
from app.models import KEY_TYPE_NORMAL, KEY_TYPE_TEAM, KEY_TYPE_TEST, ServiceGuestList
|
||||
from app.enums import RecipientType, KeyType
|
||||
from app.models import ServiceGuestList
|
||||
|
||||
|
||||
def get_recipients_from_request(request_json, key, type):
|
||||
@@ -28,10 +28,10 @@ def get_guest_list_objects(service_id, request_json):
|
||||
def service_allowed_to_send_to(
|
||||
recipient, service, key_type, allow_guest_list_recipients=True
|
||||
):
|
||||
if key_type == KEY_TYPE_TEST:
|
||||
if key_type == KeyType.TEST:
|
||||
return True
|
||||
|
||||
if key_type == KEY_TYPE_NORMAL and not service.restricted:
|
||||
if key_type == KeyType.NORMAL and not service.restricted:
|
||||
return True
|
||||
|
||||
# Revert back to the ORM model here so we can get some things which
|
||||
@@ -45,8 +45,8 @@ def service_allowed_to_send_to(
|
||||
member.recipient for member in service.guest_list if allow_guest_list_recipients
|
||||
]
|
||||
|
||||
if (key_type == KEY_TYPE_NORMAL and service.restricted) or (
|
||||
key_type == KEY_TYPE_TEAM
|
||||
if (key_type == KeyType.NORMAL and service.restricted) or (
|
||||
key_type == KeyType.TEAM
|
||||
):
|
||||
return allowed_to_send_to(
|
||||
recipient, itertools.chain(team_members, guest_list_members)
|
||||
|
||||
Reference in New Issue
Block a user