Favour new "areas" format for PagerDuty alerts

Broadcasts created via the API [1] and the Admin app [2] should
both now have this field set. It's also more informative to show
this, and broadcasts created via the API don't have IDs anyway.

There's a small risk that an old broadcast that gets approved won't
have this data, but it's for information only and we intend to
backfill all old broadcasts in the near future.

[1]: 023a06d5fb
[2]: 7dbe3afa19
This commit is contained in:
Ben Thorner
2021-08-27 14:11:59 +01:00
parent ec1171f85c
commit bf0bf4e31c
2 changed files with 14 additions and 4 deletions

View File

@@ -135,7 +135,7 @@ def send_broadcast_event(broadcast_event_id):
f'https://www.notifications.service.gov.uk/services/{broadcast_message.service_id}/current-alerts/{broadcast_message.id}', # noqa
'',
f'This broacast has been sent on channel {broadcast_message.service.broadcast_channel}.',
f'This broadcast is targeted at areas {broadcast_message.areas.get("ids", broadcast_message.areas.get("areas"))}.', # noqa
f'This broadcast is targeted at areas {broadcast_message.areas.get("names", [])}.', # noqa
''
f'This broadcast\'s content starts "{broadcast_message.content[:100]}"'
'',