create broadcast_provider_message and use id from that instead

(instead of using the id from broadcast_event)

we need every XML blob we send to have a different ID. if we're sending
different XML blobs for each provider, then each one should have a
different identifier. So, instead of taking the identifier from the
broadcast_event, take it from the broadcast_provider_message instead.

Note: We're still going to the broadcast_event for most fields, to
ensure they stay consistent between different providers. The last thing
we want is for different phone networks to get different content
This commit is contained in:
Leo Hemsted
2020-11-16 18:48:00 +00:00
parent 7cc83e04eb
commit f12c949ae9
5 changed files with 71 additions and 16 deletions

View File

@@ -6,7 +6,7 @@ from notifications_utils.statsd_decorators import statsd
from app import cbc_proxy_client, notify_celery
from app.config import QueueNames
from app.models import BroadcastEventMessageType
from app.dao.broadcast_message_dao import dao_get_broadcast_event_by_id
from app.dao.broadcast_message_dao import dao_get_broadcast_event_by_id, create_broadcast_provider_message
@notify_celery.task(name="send-broadcast-event")
@@ -26,6 +26,8 @@ def send_broadcast_event(broadcast_event_id):
def send_broadcast_provider_message(broadcast_event_id, provider):
broadcast_event = dao_get_broadcast_event_by_id(broadcast_event_id)
broadcast_provider_message = create_broadcast_provider_message(broadcast_event, provider)
current_app.logger.info(
f'invoking cbc proxy to send '
f'broadcast_event {broadcast_event.reference} '
@@ -39,7 +41,7 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
if broadcast_event.message_type == BroadcastEventMessageType.ALERT:
cbc_proxy_client.create_and_send_broadcast(
identifier=str(broadcast_event.id),
identifier=str(broadcast_provider_message.id),
headline="GOV.UK Notify Broadcast",
description=broadcast_event.transmitted_content['body'],
areas=areas,
@@ -48,7 +50,7 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
)
elif broadcast_event.message_type == BroadcastEventMessageType.UPDATE:
cbc_proxy_client.update_and_send_broadcast(
identifier=str(broadcast_event.id),
identifier=str(broadcast_provider_message.id),
headline="GOV.UK Notify Broadcast",
description=broadcast_event.transmitted_content['body'],
areas=areas,
@@ -58,7 +60,7 @@ def send_broadcast_provider_message(broadcast_event_id, provider):
)
elif broadcast_event.message_type == BroadcastEventMessageType.CANCEL:
cbc_proxy_client.cancel_broadcast(
identifier=str(broadcast_event.id),
identifier=str(broadcast_provider_message.id),
headline="GOV.UK Notify Broadcast",
description=broadcast_event.transmitted_content['body'],
areas=areas,