feat(events): mark subscriptions active on event receipt

When /api/kiosk/event receives an ONVIF event, call
markEventReceived(camera_id, topic) to flip subscription
status from pending → active (orange → green in admin UI).
Also added event_source/event_sink fields to subscription mapper.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Mitchell R 2026-05-26 05:04:11 +02:00
parent 2592a18564
commit 24f9532adf
No known key found for this signature in database
2 changed files with 7 additions and 0 deletions

View file

@ -709,6 +709,11 @@ function registerKioskRoutes(
}
}
// Mark event subscription as active (turns orange → green in admin UI)
if (body.camera_id != null && body.topic) {
repo.markEventReceived(body.camera_id, body.topic).catch(() => {});
}
// Best-effort forward to Node-RED. Topics that have a dedicated trigger
// node (bf-trigger-layout-changed etc.) expect a FLAT payload matching
// what the admin-side emit produces — splat body.payload up to the top

View file

@ -482,6 +482,8 @@ export function rowToCameraEventSubscription(r: Row): CameraEventSubscription {
topic: s(r["topic"]),
status: s(r["status"]) as EventSubscriptionStatus,
subscribed_by_kiosk_id: nn(r["subscribed_by_kiosk_id"]),
event_source: sn(r["event_source"]),
event_sink: sn(r["event_sink"]),
last_event_at: sn(r["last_event_at"]),
error_message: sn(r["error_message"]),
created_at: s(r["created_at"]),