Skip to content

Add AI home cam baby-watching state API (WATCHING / NOTWATCHING)#8

Draft
Copilot wants to merge 1 commit intomainfrom
copilot/create-watch-status-api
Draft

Add AI home cam baby-watching state API (WATCHING / NOTWATCHING)#8
Copilot wants to merge 1 commit intomainfrom
copilot/create-watch-status-api

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

Adds a singleton state resource to track whether the AI home cam is actively observing the baby, with JWT-authenticated GET and PUT endpoints.

New files

  • Entity/CamStateType — enum with WATCHING / NOTWATCHING values
  • Entity/CamState — JPA entity; singleton row (id = 1), stores @Enumerated(EnumType.STRING) state + updatedAt
  • Repository/CamStateRepository — standard JpaRepository<CamState, Long>
  • DTO/CamStateDTOsUpdateRequest (@NotNull CamStateType state) and StateResponse (state, updatedAt)
  • Service/CamStateService — upserts the singleton row; getState() returns NOTWATCHING / null as logical default when no row exists (no write on read)
  • controller/CamStateControllerGET /api/cam/state and PUT /api/cam/state

Auth

Both endpoints fall under the existing .anyRequest().authenticated() catch-all in SecurityConfig — no config changes needed. Unauthenticated requests get the standard 401 response.

API

GET /api/cam/state
Authorization: ******
→ 200 { "state": "NOTWATCHING", "updatedAt": null }

PUT /api/cam/state
Authorization: ******
{ "state": "WATCHING" }
→ 200 { "state": "WATCHING", "updatedAt": "2026-03-30T12:05:00.000Z" }

Invalid state value → 400 (Jackson enum deserialization failure)

Agent-Logs-Url: https://github.com/jowh324/BBS/sessions/59e68de0-17d8-4cfe-8174-587105722157

Co-authored-by: hgjwilly-koreatech <183201303+hgjwilly-koreatech@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants