Files
checkcle/application/src/services/ssl/notification/sslScheduleUtils.ts
T
Tola Leng 8ee933563e Notification (Telegram) for SSL notification thresholds
Ensure Telegram notifications respect warning/expiry thresholds, including manual checks.
2025-05-16 22:18:35 +08:00

27 lines
777 B
TypeScript

/**
* Check if SSL certificate daily check should run
* This helps implement the once-per-day check logic
*/
export function shouldRunDailyCheck(): boolean {
const lastRunKey = 'ssl_daily_check_last_run';
const lastRun = localStorage.getItem(lastRunKey);
if (!lastRun) {
// First time running, save timestamp and run
localStorage.setItem(lastRunKey, new Date().toISOString());
return true;
}
const lastRunDate = new Date(lastRun).setHours(0, 0, 0, 0);
const today = new Date().setHours(0, 0, 0, 0);
// If last run was not today, run again
if (lastRunDate < today) {
localStorage.setItem(lastRunKey, new Date().toISOString());
return true;
}
// Already ran today
return false;
}