This commit is contained in:
1 parent
8efd032cc6
commit
df38dccbf1
735 files changed
+128321
-120870
No files matched your search
@@ -10,29 +10,29 @@ export const dynamic = "force-dynamic";
|
||||
const AUTOPLAY_KEYS = ["radio_auto_play", "radio_autoplay"];
|
||||
|
||||
function truthy(value: string | undefined): boolean {
|
||||
if (value === undefined) return false;
|
||||
const s = value.trim().toLowerCase();
|
||||
return s === "1" || s === "true";
|
||||
if (value === undefined) return false;
|
||||
const s = value.trim().toLowerCase();
|
||||
return s === "1" || s === "true";
|
||||
}
|
||||
|
||||
export async function GET(_req: Request) {
|
||||
try {
|
||||
const rows = await prisma.websiteSetting.findMany({
|
||||
where: { key: { in: AUTOPLAY_KEYS } },
|
||||
select: { key: true, value: true },
|
||||
});
|
||||
try {
|
||||
const rows = await prisma.websiteSetting.findMany({
|
||||
where: { key: { in: AUTOPLAY_KEYS } },
|
||||
select: { key: true, value: true },
|
||||
});
|
||||
|
||||
const map: Record<string, string> = {};
|
||||
for (const row of rows) {
|
||||
map[row.key] = row.value;
|
||||
}
|
||||
const map: Record<string, string> = {};
|
||||
for (const row of rows) {
|
||||
map[row.key] = row.value;
|
||||
}
|
||||
|
||||
// Prefer the canonical key the settings page uses; fall back to the alias.
|
||||
const autoplay = truthy(map.radio_auto_play ?? map.radio_autoplay);
|
||||
// Prefer the canonical key the settings page uses; fall back to the alias.
|
||||
const autoplay = truthy(map.radio_auto_play ?? map.radio_autoplay);
|
||||
|
||||
return apiJson({ autoplay });
|
||||
} catch {
|
||||
// DB unavailable — default to no autoplay rather than a 500.
|
||||
return apiJson({ autoplay: false }, { status: 200 });
|
||||
}
|
||||
return apiJson({ autoplay });
|
||||
} catch {
|
||||
// DB unavailable — default to no autoplay rather than a 500.
|
||||
return apiJson({ autoplay: false }, { status: 200 });
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user