mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-24 01:11:38 -05:00
Only lookup broadcasts which can be cancelled
It is possible that, among the references Environment Agency give us for which broadcast to cancel, there could be references for older, already expired broadcasts. This would be the case if someone cancelled a broadcast in Notify, then issued and try to re-cancel another broadcast to the same area. The Flood Warning Service has no way of knowing that the first broadcast has been cancelled in Notify already, so it would add the reference to the list of things to be cancelled. We can avoid this from happening by filtering-out already-cancelled and expired broadcasts before looking up which one should be cancelled.
This commit is contained in:
@@ -26,6 +26,10 @@ def dao_get_broadcast_message_by_id_and_service_id(broadcast_message_id, service
|
||||
|
||||
def dao_get_broadcast_message_by_references_and_service_id(references_to_original_broadcast, service_id):
|
||||
return BroadcastMessage.query.filter(
|
||||
BroadcastMessage.status.in_((
|
||||
BroadcastStatusType.PENDING_APPROVAL,
|
||||
BroadcastStatusType.BROADCASTING,
|
||||
)),
|
||||
BroadcastMessage.reference.in_(references_to_original_broadcast),
|
||||
BroadcastMessage.service_id == service_id
|
||||
).one()
|
||||
|
||||
Reference in New Issue
Block a user