mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
Long-overdue prettier sweep; prettier had drifted vs. checked-in code across ~130 files (mostly long-argument line-break wrapping in TS and table-padding in markdown). Pure formatting — no semantic changes — and required to clear the v1.4.6 release gate's `pnpm format:check`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import { prisma } from "@/lib/db";
|
|
import { getEvent } from "@/lib/logging/context";
|
|
|
|
export interface GlobalServiceAvailability {
|
|
telegramGlobal: boolean;
|
|
ntfyGlobal: boolean;
|
|
webPushGlobal: boolean;
|
|
apiGlobal: boolean;
|
|
moodLogGlobal: boolean;
|
|
}
|
|
|
|
export async function getGlobalServiceAvailability(): Promise<GlobalServiceAvailability> {
|
|
try {
|
|
const settings = await prisma.appSettings.findUnique({
|
|
where: { id: "singleton" },
|
|
select: {
|
|
telegramGlobal: true,
|
|
ntfyGlobal: true,
|
|
webPushGlobal: true,
|
|
apiGlobal: true,
|
|
moodLogGlobal: true,
|
|
},
|
|
});
|
|
|
|
return {
|
|
telegramGlobal: settings?.telegramGlobal ?? true,
|
|
ntfyGlobal: settings?.ntfyGlobal ?? true,
|
|
webPushGlobal: settings?.webPushGlobal ?? true,
|
|
apiGlobal: settings?.apiGlobal ?? true,
|
|
moodLogGlobal: settings?.moodLogGlobal ?? true,
|
|
};
|
|
} catch {
|
|
getEvent()?.addWarning("Failed to load app settings, using defaults");
|
|
return {
|
|
telegramGlobal: true,
|
|
ntfyGlobal: true,
|
|
webPushGlobal: true,
|
|
apiGlobal: true,
|
|
moodLogGlobal: true,
|
|
};
|
|
}
|
|
}
|
|
|
|
export async function isApiGloballyEnabled(): Promise<boolean> {
|
|
const settings = await getGlobalServiceAvailability();
|
|
return settings.apiGlobal;
|
|
}
|
|
|
|
export interface ReminderThresholds {
|
|
lateMinutes: number;
|
|
missedMinutes: number;
|
|
}
|
|
|
|
export async function getReminderThresholds(): Promise<ReminderThresholds> {
|
|
try {
|
|
const settings = await prisma.appSettings.findUnique({
|
|
where: { id: "singleton" },
|
|
select: {
|
|
reminderLateMinutes: true,
|
|
reminderMissedMinutes: true,
|
|
},
|
|
});
|
|
|
|
return {
|
|
lateMinutes: settings?.reminderLateMinutes ?? 120,
|
|
missedMinutes: settings?.reminderMissedMinutes ?? 240,
|
|
};
|
|
} catch {
|
|
getEvent()?.addWarning(
|
|
"Failed to load reminder thresholds, using defaults",
|
|
);
|
|
return { lateMinutes: 120, missedMinutes: 240 };
|
|
}
|
|
}
|