create broadcast_provider_message and use id from that instead

(instead of using the id from broadcast_event)

we need every XML blob we send to have a different ID. if we're sending
different XML blobs for each provider, then each one should have a
different identifier. So, instead of taking the identifier from the
broadcast_event, take it from the broadcast_provider_message instead.

Note: We're still going to the broadcast_event for most fields, to
ensure they stay consistent between different providers. The last thing
we want is for different phone networks to get different content
This commit is contained in:
Leo Hemsted
2020-11-16 18:48:00 +00:00
parent 7cc83e04eb
commit f12c949ae9
5 changed files with 71 additions and 16 deletions

View File

@@ -1,4 +1,6 @@
from app.models import BroadcastMessage, BroadcastEvent
from app import db
from app.dao.dao_utils import transactional
from app.models import BroadcastMessage, BroadcastEvent, BroadcastProviderMessage, BroadcastProviderMessageStatus
def dao_get_broadcast_message_by_id_and_service_id(broadcast_message_id, service_id):
@@ -34,3 +36,14 @@ def get_earlier_events_for_broadcast_event(broadcast_event_id):
).order_by(
BroadcastEvent.sent_at.asc()
).all()
@transactional
def create_broadcast_provider_message(broadcast_event, provider):
provider_message = BroadcastProviderMessage(
broadcast_event=broadcast_event,
provider=provider,
status=BroadcastProviderMessageStatus.SENDING,
)
db.session.add(provider_message)
return provider_message