mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
we now no longer create a job. At the end of the post there is no action, as we don't have any tasks to queue immediately - if it's a real notification it'll get picked up in the evening scheduled task. If it's a test notification, we create it with an initial status of sending so that we can be sure it'll never get picked up - and then we trigger the update-letter-notifications-to-sent-to-dvla task to sent the sent-at/by.
24 lines
916 B
Python
24 lines
916 B
Python
from app import create_random_identifier
|
|
from app.models import LETTER_TYPE
|
|
from app.notifications.process_notifications import persist_notification
|
|
|
|
|
|
def create_letter_notification(letter_data, template, api_key, status):
|
|
notification = persist_notification(
|
|
template_id=template.id,
|
|
template_version=template.version,
|
|
# we only accept addresses_with_underscores from the API (from CSV we also accept dashes, spaces etc)
|
|
recipient=letter_data['personalisation']['address_line_1'],
|
|
service=template.service,
|
|
personalisation=letter_data['personalisation'],
|
|
notification_type=LETTER_TYPE,
|
|
api_key_id=api_key.id,
|
|
key_type=api_key.key_type,
|
|
job_id=None,
|
|
job_row_number=None,
|
|
reference=create_random_identifier(),
|
|
client_reference=letter_data.get('reference'),
|
|
status=status
|
|
)
|
|
return notification
|