From 79cf36afd51ae809efd9ae6cbaf7c730787ee0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Silvani?= Date: Mon, 12 Feb 2024 17:04:47 -0300 Subject: [PATCH] fix: On update, allow streaming if stream is not valid but event has a Test RMTP URL setup --- events/views.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/events/views.py b/events/views.py index 028ebc6..f1a4877 100644 --- a/events/views.py +++ b/events/views.py @@ -152,10 +152,17 @@ def on_update(request): ) return HttpResponseForbidden("Stream was preparing and is now active. Retry") - if not stream.is_valid_at(now): - print("[UPDATE] Stream is not valid at %s" % (now)) - return HttpResponseForbidden("Stream is not valid now") + # If stream was active and is now inactive, force disconnection + if stream.is_active_at(last_update) and not stream.is_active_at(now): + print("[UPDATE] Stream was active and is now inactive. Force disconnection.") + return HttpResponseForbidden("Stream was active and is now inactive. Retry") + + # If stream is not valid and there is no test RTMP URL for this event, force disconnection + if not stream.is_valid_at(now) and not stream.event.test_rtmp_url: + print("[UPDATE] Stream is not valid. Disconnect.") + return HttpResponseForbidden("Stream is not valid") + # Otherwise, allow return HttpResponse("OK")