Files
jeremy 6e94a0c998 feat(hobbs-organizer): v1.4.0 per-TV morning routine (admin TVs tab) + photo app 1.2.1
- Admin TVs tab: wake time/days, YouTube Music playlist, Shield volume per TV,
  pushed via 5-min TV check-ins (/api/tv/config, /api/tv/report, LAN-only)
- com.dayline.photos 1.2.1: MorningActivity (screen on, volume, playlist),
  calendar alarm at wake time, Doze-safe chained check-ins
- Both TVs configured for 06:30 daily with the family playlist

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E9NnVEico3WvFxLyjy1iW3
2026-11-04 22:48:50 -06:00

25 lines
1.3 KiB
TypeScript

import { json, readJsonBody, requireAdmin } from "../../../_lib/auth";
import { syncAll } from "../../../_lib/photos";
import { listHistory, readHistorySnapshot, saveSettings } from "../../../_lib/store";
export const dynamic = "force-dynamic";
export async function GET(request: Request) {
const denied = await requireAdmin(request);
if (denied) return denied;
return json({ history: await listHistory() });
}
/** Reverts calendars and photo settings to a snapshot (TV settings are left as they are). The current state is itself snapshotted first, so a revert can be undone. */
export async function POST(request: Request) {
const denied = await requireAdmin(request, { mutating: true });
if (denied) return denied;
const body = await readJsonBody<{ id?: string }>(request);
const snapshot = body?.id ? await readHistorySnapshot(body.id) : null;
if (!snapshot) return json({ error: "That version no longer exists." }, 404);
const saved = await saveSettings({ calendars: snapshot.calendars, photos: snapshot.photos }, `Reverted to version from ${snapshot.updatedAt}`);
console.log(`[admin] settings reverted to ${body?.id}`);
void syncAll(); // re-fetch any album the restored version brings back
return json({ ok: true, updatedAt: saved.updatedAt });
}