c2e5c1d9dc
- /photo full-screen slideshow (crossfade, blurred backdrop or fill, shuffle, date) - admin Photos tab: add shared-album links (check, sync now, status/stale warnings), slideshow options, browser-resized uploads - 6-hourly album sync scraping the share page (Library API no longer exposes user albums), caches 1920px + 64px copies in /data/photos - /api/health/photos -> 503 when an album has not synced for 48h - history/restore covers photo settings; min admin password length 6 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01E9NnVEico3WvFxLyjy1iW3
25 lines
1.2 KiB
TypeScript
25 lines
1.2 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. 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 });
|
|
}
|