add get_earlier_provider_message fn to broadcast_event

replacing get_earlier_provider_messages. The old function returned the
previous references for earlier events for a broadcast_message. However,
these depend on the message sent to a specific provider, so the function
needs to change. It now takes in a provider, and only returns
broadcast_provider_messages sent to that provider. If there are earlier
broadcast_events without a provider_message for the chosen provider, it
raises an exception - you cannot cancel a message if all the previous
events have not been created properly (as we wouldn't know what
references to cancel).
This commit is contained in:
Leo Hemsted
2020-11-17 12:35:10 +00:00
parent f12c949ae9
commit 0257774cfa
6 changed files with 72 additions and 24 deletions

View File

@@ -16,10 +16,10 @@ from app.config import BroadcastProvider
# * description is a string which populates the areaDesc field
# * polygon is a list of lat/long pairs
#
# references is a whitespace separated list of message identifiers
# previous_provider_messages is a whitespace separated list of message identifiers
# where each identifier is a previous sent message
# ie a Cancel message would have a unique identifier but have the identifier of
# the preceeding Alert message in the references field
# the preceeding Alert message in the previous_provider_messages field
class CBCProxyException(Exception):
@@ -54,7 +54,7 @@ class CBCProxyNoopClient:
# We have not implementated updating a broadcast
def update_and_send_broadcast(
self,
identifier, references, headline, description, areas,
identifier, previous_provider_messages, headline, description, areas,
sent, expires,
):
pass
@@ -62,7 +62,7 @@ class CBCProxyNoopClient:
# We have not implemented cancelling a broadcast
def cancel_broadcast(
self,
identifier, references, headline, description, areas,
identifier, previous_provider_messages, headline, description, areas,
sent, expires,
):
pass
@@ -139,7 +139,7 @@ class CBCProxyClient:
# We have not implementated updating a broadcast
def update_and_send_broadcast(
self,
identifier, references, headline, description, areas,
identifier, previous_provider_messages, headline, description, areas,
sent, expires,
):
pass
@@ -147,7 +147,7 @@ class CBCProxyClient:
# We have not implemented cancelling a broadcast
def cancel_broadcast(
self,
identifier, references, headline, description, areas,
identifier, previous_provider_messages, headline, description, areas,
sent, expires,
):
pass