jiraCloud/jobs/cron.js
jmcqueen efc64a227c Add Webex inbound OAuth flow and room-to-Jira job request pipeline.
Introduces integration-based webhook registration, message parsing, dry-run
monitoring, JSM ticket creation, and OAuth token refresh for DC Ops spaces.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-28 08:27:52 -04:00

33 lines
1.4 KiB
JavaScript

import cron from 'node-cron';
import { createCorrelationId, runWithCorrelationId } from '../lib/correlation.js';
export function scheduleJobs({ runPendingApprovals, cleanupOldLogs, runWebexOAuthMaintenance, log }) {
cron.schedule('0 30 9 * * *', async function () {
const correlationId = createCorrelationId({ routeName: 'cron' });
await runWithCorrelationId(correlationId, async () => {
try {
log.logger('cron', 'Starting scheduled job');
await runPendingApprovals();
await cleanupOldLogs();
log.logger('cron', 'Scheduled job completed');
} catch (error) {
log.logError('cron', 'Scheduled job failed', error);
}
});
});
if (runWebexOAuthMaintenance) {
cron.schedule('0 0 8 * * *', async function () {
const correlationId = createCorrelationId({ routeName: 'cron-webex-oauth' });
await runWithCorrelationId(correlationId, async () => {
try {
log.logger('cron', 'Starting Webex OAuth maintenance');
await runWebexOAuthMaintenance();
log.logger('cron', 'Webex OAuth maintenance completed');
} catch (error) {
log.logError('cron', 'Webex OAuth maintenance failed', error);
}
});
});
}
}