mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-28 21:41:45 -05:00
Validate against messages with no content
This commit is contained in:
@@ -121,6 +121,12 @@ def check_sms_content_char_count(content_count):
|
||||
raise BadRequestError(message=message)
|
||||
|
||||
|
||||
def check_if_notification_content_is_not_empty(template_with_content):
|
||||
if len(template_with_content.__str__()) == 0:
|
||||
message = 'This message is empty.'
|
||||
raise BadRequestError(message=message)
|
||||
|
||||
|
||||
def validate_template(template_id, personalisation, service, notification_type):
|
||||
try:
|
||||
template = templates_dao.dao_get_template_by_id_and_service_id(
|
||||
@@ -137,6 +143,7 @@ def validate_template(template_id, personalisation, service, notification_type):
|
||||
template_with_content = create_content_for_notification(template, personalisation)
|
||||
if template.template_type == SMS_TYPE:
|
||||
check_sms_content_char_count(template_with_content.content_count)
|
||||
check_if_notification_content_is_not_empty(template_with_content)
|
||||
return template, template_with_content
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user