Use personalisation to set client_reference for letters

which were sent through Notify interface only. This is done
to avoid performance dip from additional operation for
other notification types.
This commit is contained in:
Pea Tyczynska
2021-03-19 16:42:55 +00:00
parent a2da8bc070
commit 52c529ab3a
9 changed files with 79 additions and 49 deletions

View File

@@ -81,12 +81,16 @@ def send_one_off_notification(service_id, post_data):
allow_guest_list_recipients=False,
)
postage = None
client_reference = None
if template.template_type == LETTER_TYPE:
# Validate address and set postage to europe|rest-of-world if international letter,
# otherwise persist_notification with use template postage
postage = validate_address(service, personalisation)
if not postage:
postage = template.postage
from app.utils import get_reference_from_personalisation
client_reference = get_reference_from_personalisation(personalisation)
validate_created_by(service, post_data['created_by'])
sender_id = post_data.get('sender_id', None)
@@ -108,7 +112,8 @@ def send_one_off_notification(service_id, post_data):
created_by_id=post_data['created_by'],
reply_to_text=reply_to,
reference=create_one_off_reference(template.template_type),
postage=postage
postage=postage,
client_reference=client_reference
)
queue_name = QueueNames.PRIORITY if template.process_type == PRIORITY else None