mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
+33
-15
@@ -5,40 +5,58 @@
|
||||
* Same shape as admin.cron.js — each job module exports
|
||||
* { name, schedule, run }, listed in the `jobs` array below.
|
||||
*
|
||||
* All three are settings-backed (see cronRegistry.util.js) —
|
||||
* The settings-backed jobs emit notifications, so their
|
||||
* schedule/enabled state lives in cron_notification_settings
|
||||
* and is configurable from /admin/notifications/settings
|
||||
* without a restart.
|
||||
* without a restart. expireAdvertisements has no notification
|
||||
* tied to it, so it stays on a plain hardcoded schedule (same
|
||||
* reasoning as liftExpiredBans in admin.cron.js).
|
||||
*
|
||||
* Currently registered:
|
||||
* - userNotifications (cron/jobs/user_notifications.cron.js)
|
||||
* - issueCertificates (cron/jobs/issue_certificates.cron.js)
|
||||
* - expireUserTiers (cron/jobs/expire_user_tiers.cron.js)
|
||||
* - userNotifications (cron/jobs/user_notifications.cron.js)
|
||||
* - issueCertificates (cron/jobs/issue_certificates.cron.js)
|
||||
* - expireUserTiers (cron/jobs/expire_user_tiers.cron.js)
|
||||
* - taskDueSoon (cron/jobs/task_due_soon.cron.js)
|
||||
* - expireAdvertisements (cron/jobs/expire_advertisements.cron.js) — plain
|
||||
*
|
||||
* Author: Kenneth Obsequio (@lash0000)
|
||||
* Date Created: Jun. 17, 2026
|
||||
***********************************************************************************************************************************************************************/
|
||||
const userNotifications = require('./jobs/user_notifications.cron');
|
||||
const issueCertificates = require('./jobs/issue_certificates.cron');
|
||||
const expireUserTiers = require('./jobs/expire_user_tiers.cron');
|
||||
const taskDueSoon = require('./jobs/task_due_soon.cron');
|
||||
const cron = require('node-cron');
|
||||
const userNotifications = require('./jobs/user_notifications.cron');
|
||||
const issueCertificates = require('./jobs/issue_certificates.cron');
|
||||
const expireUserTiers = require('./jobs/expire_user_tiers.cron');
|
||||
const taskDueSoon = require('./jobs/task_due_soon.cron');
|
||||
const expireAdvertisements = require('./jobs/expire_advertisements.cron');
|
||||
const { startSettingsBackedJobs } = require('./cronRegistry.util');
|
||||
|
||||
// TODO(ads-7): Add an `expire_advertisements.cron.js` job (same shape as
|
||||
// expire_user_tiers.cron.js) that auto-archives (soft-deletes) advertisements
|
||||
// once their end_date has passed, instead of just leaving them at derived
|
||||
// status "expired" forever. Register it in the `jobs` array below.
|
||||
// ─── Registry — add future client-side cron jobs here ────────────────────────
|
||||
const jobs = [
|
||||
const settingsBackedJobs = [
|
||||
userNotifications,
|
||||
issueCertificates,
|
||||
expireUserTiers,
|
||||
taskDueSoon,
|
||||
];
|
||||
|
||||
// Plain hardcoded-schedule jobs (not tied to any notification setting).
|
||||
const plainJobs = [
|
||||
expireAdvertisements,
|
||||
];
|
||||
|
||||
// ─── Boot all registered client-side jobs ─────────────────────────────────────
|
||||
async function startClientCronJobs() {
|
||||
return startSettingsBackedJobs(jobs, 'CLIENT');
|
||||
const registered = await startSettingsBackedJobs(settingsBackedJobs, 'CLIENT');
|
||||
|
||||
for (const job of plainJobs) {
|
||||
if (!cron.validate(job.schedule)) {
|
||||
console.error(`[CRON][CLIENT] Invalid schedule for "${job.name}": "${job.schedule}" — skipped.`);
|
||||
continue;
|
||||
}
|
||||
cron.schedule(job.schedule, job.run);
|
||||
registered.push({ name: job.name, scope: 'CLIENT', schedule: job.schedule });
|
||||
}
|
||||
|
||||
return registered;
|
||||
}
|
||||
|
||||
module.exports = { startClientCronJobs };
|
||||
|
||||
Reference in New Issue
Block a user