Trigger task to publish alerts when sending or cancelling alert

When we send or cancel a broadcast message, we now trigger a task
in govuk-alerts repo that polls our API for alerts and
publishes a fresh list of alerts.

Co-authored-by: Pea Tyczynska <pea.tyczynska@digital.cabinet-office.gov.uk>
This commit is contained in:
Katie Smith
2021-10-15 11:39:15 +01:00
parent c84daf0b7b
commit 04bfd6bfdb
3 changed files with 52 additions and 1 deletions

View File

@@ -7,7 +7,7 @@ from notifications_utils.clients.zendesk.zendesk_client import (
from app import cbc_proxy_client, notify_celery, zendesk_client
from app.clients.cbc_proxy import CBCProxyRetryableException
from app.config import QueueNames
from app.config import QueueNames, TaskNames
from app.dao.broadcast_message_dao import (
create_broadcast_provider_message,
dao_get_broadcast_event_by_id,
@@ -157,6 +157,11 @@ def send_broadcast_event(broadcast_event_id):
zendesk_client.send_ticket_to_zendesk(ticket)
current_app.logger.error(message)
notify_celery.send_task(
name=TaskNames.PUBLISH_GOVUK_ALERTS,
queue=QueueNames.GOVUK_ALERTS
)
for provider in broadcast_event.service.get_available_broadcast_providers():
send_broadcast_provider_message.apply_async(
kwargs={'broadcast_event_id': broadcast_event_id, 'provider': provider},

View File

@@ -35,6 +35,7 @@ class QueueNames(object):
SAVE_API_EMAIL = 'save-api-email-tasks'
SAVE_API_SMS = 'save-api-sms-tasks'
BROADCASTS = 'broadcast-tasks'
GOVUK_ALERTS = 'govuk-alerts'
@staticmethod
def all_queues():
@@ -75,6 +76,7 @@ class TaskNames(object):
SCAN_FILE = 'scan-file'
SANITISE_LETTER = 'sanitise-and-upload-letter'
CREATE_PDF_FOR_TEMPLATED_LETTER = 'create-pdf-for-templated-letter'
PUBLISH_GOVUK_ALERTS = 'publish-govuk-alerts'
class Config(object):