mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Add the recipient address in the "to" field for precompiled letters.
This commit is contained in:
@@ -255,7 +255,8 @@ def process_virus_scan_passed(self, filename):
|
|||||||
update_letter_pdf_status(
|
update_letter_pdf_status(
|
||||||
reference=reference,
|
reference=reference,
|
||||||
status=NOTIFICATION_DELIVERED if is_test_key else NOTIFICATION_CREATED,
|
status=NOTIFICATION_DELIVERED if is_test_key else NOTIFICATION_CREATED,
|
||||||
billable_units=billable_units
|
billable_units=billable_units,
|
||||||
|
recipient_address=sanitise_response.get("recipient_address")
|
||||||
)
|
)
|
||||||
scan_pdf_object.delete()
|
scan_pdf_object.delete()
|
||||||
except BotoClientError:
|
except BotoClientError:
|
||||||
@@ -308,6 +309,7 @@ def process_sanitised_letter(
|
|||||||
validation_status,
|
validation_status,
|
||||||
filename,
|
filename,
|
||||||
notification_id,
|
notification_id,
|
||||||
|
recipient_address=None
|
||||||
):
|
):
|
||||||
current_app.logger.info('Processing sanitised letter with id {}'.format(notification_id))
|
current_app.logger.info('Processing sanitised letter with id {}'.format(notification_id))
|
||||||
notification = get_notification_by_id(notification_id, _raise=True)
|
notification = get_notification_by_id(notification_id, _raise=True)
|
||||||
@@ -474,14 +476,14 @@ def process_virus_scan_error(filename):
|
|||||||
raise error
|
raise error
|
||||||
|
|
||||||
|
|
||||||
def update_letter_pdf_status(reference, status, billable_units):
|
def update_letter_pdf_status(reference, status, billable_units, recipient_address=None):
|
||||||
|
|
||||||
|
update_dict = {'status': status, 'billable_units': billable_units, 'updated_at': datetime.utcnow()}
|
||||||
|
if recipient_address:
|
||||||
|
update_dict['to'] = recipient_address
|
||||||
return dao_update_notifications_by_reference(
|
return dao_update_notifications_by_reference(
|
||||||
references=[reference],
|
references=[reference],
|
||||||
update_dict={
|
update_dict=update_dict)[0]
|
||||||
'status': status,
|
|
||||||
'billable_units': billable_units,
|
|
||||||
'updated_at': datetime.utcnow()
|
|
||||||
})[0]
|
|
||||||
|
|
||||||
|
|
||||||
def replay_letters_in_error(filename=None):
|
def replay_letters_in_error(filename=None):
|
||||||
|
|||||||
@@ -440,6 +440,7 @@ def test_process_letter_task_check_virus_scan_passed(
|
|||||||
endpoint,
|
endpoint,
|
||||||
json={
|
json={
|
||||||
"file": base64.b64encode(b"new_pdf").decode("utf-8"),
|
"file": base64.b64encode(b"new_pdf").decode("utf-8"),
|
||||||
|
"recipient_address": "Bugs Bunny",
|
||||||
"validation_passed": True,
|
"validation_passed": True,
|
||||||
"message": "",
|
"message": "",
|
||||||
"invalid_pages": [],
|
"invalid_pages": [],
|
||||||
|
|||||||
Reference in New Issue
Block a user