Merge pull request #3993 from alphagov/4-hours-expiry-test-channels

Expire test and operator alerts after 4 hours
This commit is contained in:
Chris Hill-Scott
2021-08-18 10:12:26 +01:00
committed by GitHub
3 changed files with 23 additions and 7 deletions

View File

@@ -449,14 +449,14 @@ def approve_broadcast_message(service_id, broadcast_message_id):
))
if current_service.trial_mode:
broadcast_message.approve_broadcast()
broadcast_message.approve_broadcast(channel=current_service.broadcast_channel)
return redirect(url_for(
'.broadcast_tour',
service_id=current_service.id,
step_index=6,
))
elif form.validate_on_submit():
broadcast_message.approve_broadcast()
broadcast_message.approve_broadcast(channel=current_service.broadcast_channel)
else:
return render_template(
'views/broadcast/view-message.html',

View File

@@ -248,12 +248,15 @@ class BroadcastMessage(JSONModel):
def request_approval(self):
self._set_status_to('pending-approval')
def approve_broadcast(self):
def approve_broadcast(self, channel):
if channel in {'test', 'operator'}:
ttl = timedelta(hours=4, minutes=0)
else:
ttl = timedelta(hours=22, minutes=30)
self._update(
starts_at=datetime.utcnow().isoformat(),
finishes_at=(
datetime.utcnow() + timedelta(hours=23, minutes=59)
).isoformat(),
finishes_at=(datetime.utcnow() + ttl).isoformat(),
)
self._set_status_to('broadcasting')