mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-14 23:07:49 -04:00
Merge pull request #2729 from alphagov/validate_send_file_by_email_contact_deets
All services can send files by email if they have set contact_link
This commit is contained in:
@@ -85,7 +85,16 @@ def service_has_permission(notify_type, permissions):
|
||||
def check_service_has_permission(notify_type, permissions):
|
||||
if not service_has_permission(notify_type, permissions):
|
||||
raise BadRequestError(message="Service is not allowed to send {}".format(
|
||||
get_public_notify_type_text(notify_type, plural=True)))
|
||||
get_public_notify_type_text(notify_type, plural=True)
|
||||
))
|
||||
|
||||
|
||||
def check_if_service_can_send_files_by_email(service_contact_link, service_id):
|
||||
if not service_contact_link:
|
||||
raise BadRequestError(
|
||||
message=f"Send files by email has not been set up - add contact details for your service at "
|
||||
f"{current_app.config['ADMIN_BASE_URL']}/services/{service_id}/service-settings/send-files-by-email"
|
||||
)
|
||||
|
||||
|
||||
def check_service_can_schedule_notification(permissions, scheduled_for):
|
||||
|
||||
@@ -16,7 +16,6 @@ from app.models import (
|
||||
SMS_TYPE,
|
||||
EMAIL_TYPE,
|
||||
LETTER_TYPE,
|
||||
UPLOAD_DOCUMENT,
|
||||
PRIORITY,
|
||||
KEY_TYPE_TEST,
|
||||
KEY_TYPE_TEAM,
|
||||
@@ -35,13 +34,14 @@ from app.notifications.process_notifications import (
|
||||
simulated_recipient
|
||||
)
|
||||
from app.notifications.validators import (
|
||||
validate_and_format_recipient,
|
||||
check_if_service_can_send_files_by_email,
|
||||
check_rate_limiting,
|
||||
check_service_can_schedule_notification,
|
||||
check_service_has_permission,
|
||||
validate_template,
|
||||
check_service_email_reply_to_id,
|
||||
check_service_sms_sender_id
|
||||
check_service_has_permission,
|
||||
check_service_sms_sender_id,
|
||||
validate_and_format_recipient,
|
||||
validate_template,
|
||||
)
|
||||
from app.schema_validation import validate
|
||||
from app.v2.errors import BadRequestError
|
||||
@@ -235,7 +235,10 @@ def process_document_uploads(personalisation_data, service, simulated=False):
|
||||
|
||||
personalisation_data = personalisation_data.copy()
|
||||
|
||||
check_service_has_permission(UPLOAD_DOCUMENT, authenticated_service.permissions)
|
||||
check_if_service_can_send_files_by_email(
|
||||
service_contact_link=authenticated_service.contact_link,
|
||||
service_id=authenticated_service.id
|
||||
)
|
||||
|
||||
for key in file_keys:
|
||||
if simulated:
|
||||
|
||||
Reference in New Issue
Block a user