add send_broadcast_message task

task takes a brodcast_message_id, and makes a post to the cbc-proxy
for now, hardcode the url to the notify stub. the stub requires template
as the admin/api get it, so use the marshmallow schema to json dump it.
Note - this also required us to tweak the BroadcastMessage.serialize
function so that it converts uuids in to ids - flask's jsonify function
does that for free but requests.post doesn't sadly.

if the request fails (either 4xx or 5xx) just raise an exception and let
it bubble up for now - in the future we'll add retry logic
This commit is contained in:
Leo Hemsted
2020-07-09 18:22:29 +01:00
parent fb64cbe621
commit eca37d0853
5 changed files with 116 additions and 6 deletions

View File

@@ -112,6 +112,9 @@ class Config(object):
# Antivirus
ANTIVIRUS_ENABLED = True
# Broadcast Messaging
CBC_PROXY_URL = None
###########################
# Default config values ###
###########################
@@ -393,6 +396,8 @@ 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'
@@ -436,6 +441,8 @@ 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'
@@ -452,6 +459,7 @@ 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-sandbox.cloudapps.digital'
FROM_NUMBER = 'preview'
API_RATE_LIMIT_ENABLED = True
CHECK_PROXY_HEADER = False
@@ -469,6 +477,7 @@ 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-sandbox.cloudapps.digital'
FROM_NUMBER = 'stage'
API_RATE_LIMIT_ENABLED = True
CHECK_PROXY_HEADER = True
@@ -487,6 +496,7 @@ 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-sandbox.cloudapps.digital'
FROM_NUMBER = 'GOVUK'
PERFORMANCE_PLATFORM_ENABLED = True
API_RATE_LIMIT_ENABLED = True