mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
broadcasts: remove references to cbc stub
We are phasing out our cbc-proxy stub which displayed CAP XML messages We are in the process of testing with real CBCs, so maintaining our own stub is not useful This commit * removes the HTTP POST requests to the CBC proxy * writes up the update/cancel methods of the cbc_client (not impl) Signed-off-by: Toby Lorne <toby.lornewelch-richards@digital.cabinet-office.gov.uk>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import requests
|
||||
from flask import current_app
|
||||
from notifications_utils.statsd_decorators import statsd
|
||||
|
||||
@@ -10,45 +9,43 @@ from app.dao.broadcast_message_dao import dao_get_broadcast_event_by_id
|
||||
|
||||
@notify_celery.task(name="send-broadcast-event")
|
||||
@statsd(namespace="tasks")
|
||||
def send_broadcast_event(broadcast_event_id, provider='stub-1'):
|
||||
def send_broadcast_event(broadcast_event_id):
|
||||
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}'
|
||||
current_app.logger.info(
|
||||
f'invoking cbc proxy to send '
|
||||
f'broadcast_event {broadcast_event.reference} '
|
||||
f'msgType {broadcast_event.message_type}'
|
||||
)
|
||||
|
||||
areas = [
|
||||
{"description": desc, "polygon": polygon}
|
||||
for desc, polygon in zip(
|
||||
broadcast_event.transmitted_areas["areas"],
|
||||
broadcast_event.transmitted_areas["simple_polygons"],
|
||||
)
|
||||
]
|
||||
|
||||
areas = [
|
||||
{"description": desc, "polygon": polygon}
|
||||
for desc, polygon in zip(
|
||||
broadcast_event.transmitted_areas["areas"],
|
||||
broadcast_event.transmitted_areas["simple_polygons"],
|
||||
)
|
||||
]
|
||||
|
||||
if broadcast_event.message_type == BroadcastEventMessageType.ALERT:
|
||||
cbc_proxy_client.create_and_send_broadcast(
|
||||
identifier=str(broadcast_event.id),
|
||||
headline="GOV.UK Notify Broadcast",
|
||||
description=broadcast_event.transmitted_content['body'],
|
||||
areas=areas,
|
||||
)
|
||||
|
||||
current_app.logger.info(
|
||||
f'sending broadcast_event {broadcast_event.reference} '
|
||||
f'msgType {broadcast_event.message_type} to {provider}'
|
||||
)
|
||||
|
||||
payload = broadcast_event.serialize()
|
||||
|
||||
resp = requests.post(
|
||||
f'{current_app.config["CBC_PROXY_URL"]}/broadcasts/events/{provider}',
|
||||
json=payload
|
||||
)
|
||||
resp.raise_for_status()
|
||||
|
||||
current_app.logger.info(
|
||||
f'broadcast_event {broadcast_event.reference} '
|
||||
f'msgType {broadcast_event.message_type} sent to {provider}'
|
||||
)
|
||||
elif broadcast_event.message_type == BroadcastEventMessageType.UPDATE:
|
||||
cbc_proxy_client.update_and_send_broadcast(
|
||||
identifier=str(broadcast_event.id),
|
||||
headline="GOV.UK Notify Broadcast",
|
||||
description=broadcast_event.transmitted_content['body'],
|
||||
areas=areas,
|
||||
references=broadcast_event.get_earlier_message_references(),
|
||||
)
|
||||
elif broadcast_event.message_type == BroadcastEventMessageType.CANCEL:
|
||||
cbc_proxy_client.cancel_broadcast(
|
||||
identifier=str(broadcast_event.id),
|
||||
headline="GOV.UK Notify Broadcast",
|
||||
description=broadcast_event.transmitted_content['body'],
|
||||
areas=areas,
|
||||
references=broadcast_event.get_earlier_message_references(),
|
||||
)
|
||||
|
||||
@@ -112,9 +112,6 @@ class Config(object):
|
||||
# Antivirus
|
||||
ANTIVIRUS_ENABLED = True
|
||||
|
||||
# Broadcast Messaging
|
||||
CBC_PROXY_URL = None
|
||||
|
||||
###########################
|
||||
# Default config values ###
|
||||
###########################
|
||||
@@ -402,8 +399,6 @@ class Development(Config):
|
||||
API_HOST_NAME = "http://localhost:6011"
|
||||
API_RATE_LIMIT_ENABLED = True
|
||||
|
||||
CBC_PROXY_URL = 'http://localhost:8080'
|
||||
|
||||
|
||||
class Test(Development):
|
||||
NOTIFY_EMAIL_DOMAIN = 'test.notify.com'
|
||||
@@ -447,8 +442,6 @@ class Test(Development):
|
||||
FIRETEXT_INBOUND_SMS_AUTH = ['testkey']
|
||||
TEMPLATE_PREVIEW_API_HOST = 'http://localhost:9999'
|
||||
|
||||
CBC_PROXY_URL = 'http://test-cbc-proxy'
|
||||
|
||||
MMG_URL = 'https://example.com/mmg'
|
||||
FIRETEXT_URL = 'https://example.com/firetext'
|
||||
|
||||
@@ -465,7 +458,6 @@ class Preview(Config):
|
||||
INVALID_PDF_BUCKET_NAME = 'preview-letters-invalid-pdf'
|
||||
TRANSIENT_UPLOADED_LETTERS = 'preview-transient-uploaded-letters'
|
||||
LETTER_SANITISE_BUCKET_NAME = 'preview-letters-sanitise'
|
||||
CBC_PROXY_URL = 'https://notify-stub-cbc-preview.cloudapps.digital'
|
||||
FROM_NUMBER = 'preview'
|
||||
API_RATE_LIMIT_ENABLED = True
|
||||
CHECK_PROXY_HEADER = False
|
||||
@@ -483,7 +475,6 @@ class Staging(Config):
|
||||
INVALID_PDF_BUCKET_NAME = 'staging-letters-invalid-pdf'
|
||||
TRANSIENT_UPLOADED_LETTERS = 'staging-transient-uploaded-letters'
|
||||
LETTER_SANITISE_BUCKET_NAME = 'staging-letters-sanitise'
|
||||
CBC_PROXY_URL = 'https://notify-stub-cbc-staging.cloudapps.digital'
|
||||
FROM_NUMBER = 'stage'
|
||||
API_RATE_LIMIT_ENABLED = True
|
||||
CHECK_PROXY_HEADER = True
|
||||
@@ -501,7 +492,6 @@ class Live(Config):
|
||||
INVALID_PDF_BUCKET_NAME = 'production-letters-invalid-pdf'
|
||||
TRANSIENT_UPLOADED_LETTERS = 'production-transient-uploaded-letters'
|
||||
LETTER_SANITISE_BUCKET_NAME = 'production-letters-sanitise'
|
||||
CBC_PROXY_URL = 'https://notify-stub-cbc-production.cloudapps.digital'
|
||||
FROM_NUMBER = 'GOVUK'
|
||||
PERFORMANCE_PLATFORM_ENABLED = True
|
||||
API_RATE_LIMIT_ENABLED = True
|
||||
|
||||
Reference in New Issue
Block a user