mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
celery: broadcast msg create invokes cbc proxy
When we create a broadcast message, we should invoke the cbc proxy to send a cap message Either a function will be invoked within AWS, or a noop function call is made, depending on the environment We have only implemented CB message creation in the CBC Proxy, without polygons, therefore we: * only invoke the CBC Proxy during message creation * only send description, identifier, and hard-coded headline Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk> Co-authored-by: Pea <pea.tyczynska@digital.cabinet-office.gov.uk> Co-authored-by: Katie <katie.smith@digital.cabinet-office.gov.uk>
This commit is contained in:
@@ -2,8 +2,9 @@ import requests
|
||||
from flask import current_app
|
||||
from notifications_utils.statsd_decorators import statsd
|
||||
|
||||
from app import notify_celery
|
||||
from app import cbc_proxy_client, notify_celery
|
||||
|
||||
from app.models import BroadcastEventMessageType
|
||||
from app.dao.broadcast_message_dao import dao_get_broadcast_event_by_id
|
||||
|
||||
|
||||
@@ -12,6 +13,19 @@ from app.dao.broadcast_message_dao import dao_get_broadcast_event_by_id
|
||||
def send_broadcast_event(broadcast_event_id, provider='stub-1'):
|
||||
broadcast_event = dao_get_broadcast_event_by_id(broadcast_event_id)
|
||||
|
||||
if broadcast_event.message_type == BroadcastEventMessageType.ALERT:
|
||||
current_app.logger.info(
|
||||
f'invoking cbc proxy to send '
|
||||
f'broadcast_event {broadcast_event.reference} '
|
||||
f'msgType {broadcast_event.message_type} to {provider}'
|
||||
)
|
||||
|
||||
cbc_proxy_client.create_and_send_broadcast(
|
||||
identifier=str(broadcast_event.id),
|
||||
headline="GOV.UK Notify Broadcast",
|
||||
description=broadcast_event.transmitted_content['body'],
|
||||
)
|
||||
|
||||
current_app.logger.info(
|
||||
f'sending broadcast_event {broadcast_event.reference} '
|
||||
f'msgType {broadcast_event.message_type} to {provider}'
|
||||
|
||||
Reference in New Issue
Block a user