mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Save the first non-empty line as recipient
Since we now allow the address to be populated from any three lines, we can’t guarantee that the recipient will be in the `addressline1` field.
This commit is contained in:
@@ -3,6 +3,8 @@ from datetime import datetime
|
||||
from collections import namedtuple, defaultdict
|
||||
|
||||
from flask import current_app
|
||||
from notifications_utils.columns import Columns
|
||||
from notifications_utils.postal_address import PostalAddress
|
||||
from notifications_utils.recipients import RecipientCSV
|
||||
from notifications_utils.statsd_decorators import statsd
|
||||
from notifications_utils.timezones import convert_utc_to_bst
|
||||
@@ -341,7 +343,9 @@ def save_letter(
|
||||
notification = encryption.decrypt(encrypted_notification)
|
||||
|
||||
# we store the recipient as just the first item of the person's address
|
||||
recipient = notification['personalisation']['addressline1']
|
||||
recipient = PostalAddress.from_personalisation(
|
||||
Columns(notification['personalisation'])
|
||||
).normalised_lines[0]
|
||||
|
||||
service = dao_fetch_service_by_id(service_id)
|
||||
template = dao_get_template_by_id(notification['template'], version=notification['template_version'])
|
||||
|
||||
Reference in New Issue
Block a user