From 24f9532adf336b6c426eed76b02869b33af00d4e Mon Sep 17 00:00:00 2001 From: Mitchell R Date: Tue, 26 May 2026 05:04:11 +0200 Subject: [PATCH] feat(events): mark subscriptions active on event receipt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- server/src/plugins/service-api-http/index.ts | 5 +++++ server/src/shared/db/mappers.ts | 2 ++ 2 files changed, 7 insertions(+) diff --git a/server/src/plugins/service-api-http/index.ts b/server/src/plugins/service-api-http/index.ts index 2346638..5cd0701 100644 --- a/server/src/plugins/service-api-http/index.ts +++ b/server/src/plugins/service-api-http/index.ts @@ -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 diff --git a/server/src/shared/db/mappers.ts b/server/src/shared/db/mappers.ts index 2567156..d73bf2a 100644 --- a/server/src/shared/db/mappers.ts +++ b/server/src/shared/db/mappers.ts @@ -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"]),