mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-12-06 21:44:13 +03:00
Specifically validate provided end_time for manual events
This commit is contained in:
parent
f2ce5572bd
commit
f6a5e9819e
@ -1652,10 +1652,27 @@ async def end_event(request: Request, event_id: str, body: EventsEndBody):
|
|||||||
try:
|
try:
|
||||||
event: Event = Event.get(Event.id == event_id)
|
event: Event = Event.get(Event.id == event_id)
|
||||||
await require_camera_access(event.camera, request=request)
|
await require_camera_access(event.camera, request=request)
|
||||||
|
|
||||||
|
if body.end_time is not None and body.end_time < event.start_time:
|
||||||
|
return JSONResponse(
|
||||||
|
content=(
|
||||||
|
{
|
||||||
|
"success": False,
|
||||||
|
"message": f"end_time ({body.end_time}) cannot be before start_time ({event.start_time}).",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
status_code=400,
|
||||||
|
)
|
||||||
|
|
||||||
end_time = body.end_time or datetime.datetime.now().timestamp()
|
end_time = body.end_time or datetime.datetime.now().timestamp()
|
||||||
request.app.event_metadata_updater.publish(
|
request.app.event_metadata_updater.publish(
|
||||||
(event_id, end_time), EventMetadataTypeEnum.manual_event_end.value
|
(event_id, end_time), EventMetadataTypeEnum.manual_event_end.value
|
||||||
)
|
)
|
||||||
|
except DoesNotExist:
|
||||||
|
return JSONResponse(
|
||||||
|
content=({"success": False, "message": f"Event {event_id} not found."}),
|
||||||
|
status_code=404,
|
||||||
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
content=(
|
content=(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user