mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 23:55:58 -05:00
Change how we validate the length of templates.
We want to add validation for an email that's too long, that way the user knows why the message is failing. At the moment if an email is too long it will get a technical failure, after the retries fail. This way the email post will get a validation error. Once this: https://github.com/alphagov/notifications-utils/pull/804 is reverted, we can update the utils version.
This commit is contained in:
@@ -52,7 +52,7 @@ from app.notifications.validators import (
|
||||
validate_address,
|
||||
validate_and_format_recipient,
|
||||
validate_template,
|
||||
)
|
||||
check_content_char_count)
|
||||
from app.schema_validation import validate
|
||||
from app.v2.errors import BadRequestError
|
||||
from app.v2.notifications.create_response import (
|
||||
@@ -132,6 +132,7 @@ def post_notification(notification_type):
|
||||
form.get('personalisation', {}),
|
||||
authenticated_service,
|
||||
notification_type,
|
||||
check_char_count=False
|
||||
)
|
||||
|
||||
reply_to = get_reply_to_text(notification_type, form, template)
|
||||
@@ -189,6 +190,9 @@ def process_sms_or_email_notification(
|
||||
# We changed personalisation which means we need to update the content
|
||||
template_with_content.values = personalisation
|
||||
|
||||
# validate content length after url is replaced in personalisation.
|
||||
check_content_char_count(template_with_content)
|
||||
|
||||
resp = create_response_for_post_notification(
|
||||
notification_id=notification_id,
|
||||
client_reference=form.get('reference', None),
|
||||
|
||||
Reference in New Issue
Block a user