Commit 1a969f4
ops(motion): per-org server-side kill switch for motion-event ingestion
Closes the motion-runaway scenario from yesterday's SaaS-readiness
review: there was no way to stop a misbehaving / mis-configured
sensor from flooding events into MotionEvent without reaching the
node itself. The per-camera recording policy is the granularity
operators usually want, but if a sensor is producing hundreds of
events per second it's faster to flip a server-side switch than to
SSH to the node and reconfigure FFmpeg's scene-change threshold.
Changes:
- hls.py POST /motion: short-circuit before recording when
Setting `motion_ingestion_enabled` is "false" for the camera's
org. Returns 200 + ingested:false rather than 4xx so the
CloudNode treats this as a by-design rejection (same shape as
the plan-cap suspension path) and doesn't burn its retry
budget. Default "true" so orgs that never touch the toggle
keep the original always-ingest behaviour.
- cameras.py: new GET + POST /api/settings/motion-ingestion (admin
for write, viewer for read). Mirrors the notifications/timezone
settings pattern: stored in the existing Setting key/value table,
no schema migration needed. Audited so there's a record of who
flipped it.
- 3 new tests pinning the kill-switch shape: default enabled,
toggle persists across GET, viewer can't flip the switch.
This is the one of the cheap fixes from the SaaS-readiness review.
Costs ~30 lines of code, gives operators an immediate stop-bleeding
lever for a real failure mode.
290 backend tests pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 17e12a7 commit 1a969f4
3 files changed
Lines changed: 98 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
439 | 490 | | |
440 | 491 | | |
441 | 492 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| |||
708 | 709 | | |
709 | 710 | | |
710 | 711 | | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
711 | 723 | | |
712 | 724 | | |
713 | 725 | | |
| |||
723 | 735 | | |
724 | 736 | | |
725 | 737 | | |
726 | | - | |
| 738 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
90 | 124 | | |
91 | 125 | | |
92 | 126 | | |
| |||
0 commit comments