PATCH: Added check to see if stream ever published in /end_stream, otherwise errors occured
This commit is contained in:
@@ -173,7 +173,7 @@ def init_stream():
|
|||||||
"""
|
"""
|
||||||
stream_key = request.form.get("name")
|
stream_key = request.form.get("name")
|
||||||
|
|
||||||
print(f"Stream initialization requested in nginx with key: {stream_key}")
|
print(f"Stream initialization requested in nginx with key: {stream_key}", flush=True)
|
||||||
|
|
||||||
with Database() as db:
|
with Database() as db:
|
||||||
# Check if valid stream key and user is allowed to stream
|
# Check if valid stream key and user is allowed to stream
|
||||||
@@ -315,6 +315,11 @@ def end_stream():
|
|||||||
print("Unauthorized - No user found from stream key", flush=True)
|
print("Unauthorized - No user found from stream key", flush=True)
|
||||||
return "Unauthorized", 403
|
return "Unauthorized", 403
|
||||||
|
|
||||||
|
# If stream never published, return
|
||||||
|
if not stream_info:
|
||||||
|
print("Stream never began", flush=True)
|
||||||
|
return "Stream ended", 200
|
||||||
|
|
||||||
# Remove stream from database
|
# Remove stream from database
|
||||||
db.execute("""DELETE FROM streams
|
db.execute("""DELETE FROM streams
|
||||||
WHERE user_id = ?""", (user_info["user_id"],))
|
WHERE user_id = ?""", (user_info["user_id"],))
|
||||||
|
|||||||
Reference in New Issue
Block a user