mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 08:21:13 -05:00
Use utils template to format broadcast content
Brings in: - [x] https://github.com/alphagov/notifications-utils/pull/801 Formats the content of the template at the time of creating the event. This means that any downstream code (eg Celery tasks) can assume the content is already formatted correctly. Also, these downstream tasks don’t know which template the broadcast was created from, so if we support personalisation in the future this is the most sensible place to bring together the template and the personalisation. --- I had to re-create some of the deleted code from utils for stuff like formatting the timestamp to the CAP standard.
This commit is contained in:
@@ -185,13 +185,16 @@ def _create_broadcast_event(broadcast_message):
|
||||
else:
|
||||
transmitted_finishes_at = broadcast_message.finishes_at
|
||||
|
||||
# TODO: This doesn't support placeholders yet. We shouldn't use BroadcastMessageTemplate when we add placeholders
|
||||
# as that just outputs XML, we need the raw text.
|
||||
template = broadcast_message.template._as_utils_template_with_personalisation(
|
||||
# Broadcast events don’t support personalisation yet
|
||||
values={}
|
||||
)
|
||||
|
||||
event = BroadcastEvent(
|
||||
service=broadcast_message.service,
|
||||
broadcast_message=broadcast_message,
|
||||
message_type=msg_types[broadcast_message.status],
|
||||
transmitted_content={"body": broadcast_message.template.content},
|
||||
transmitted_content={"body": str(template)},
|
||||
transmitted_areas=broadcast_message.areas,
|
||||
# TODO: Probably move this somewhere more standalone too and imply that it shouldn't change. Should it include
|
||||
# a service based identifier too? eg "flood-warnings@notifications.service.gov.uk" or similar
|
||||
|
||||
Reference in New Issue
Block a user