mirror of
https://github.com/GSA/notifications-api.git
synced 2026-08-18 05:28:49 -04:00
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:
@@ -62,7 +62,8 @@ from app.models import (
|
||||
ServiceContactList,
|
||||
BroadcastMessage,
|
||||
BroadcastStatusType,
|
||||
BroadcastEvent
|
||||
BroadcastEvent,
|
||||
BroadcastProviderMessage
|
||||
)
|
||||
|
||||
|
||||
@@ -1050,3 +1051,18 @@ def create_broadcast_event(
|
||||
db.session.add(b_e)
|
||||
db.session.commit()
|
||||
return b_e
|
||||
|
||||
|
||||
def create_broadcast_provider_message(
|
||||
broadcast_event,
|
||||
provider,
|
||||
status='sending'
|
||||
):
|
||||
provider_message = BroadcastProviderMessage(
|
||||
broadcast_event=broadcast_event,
|
||||
provider=provider,
|
||||
status=status
|
||||
)
|
||||
db.session.add(provider_message)
|
||||
db.session.commit()
|
||||
return provider_message
|
||||
|
||||
Reference in New Issue
Block a user