feat: delete users - not tested
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
import cron from 'node-cron';
|
||||
import { logger } from '../logging/logger';
|
||||
import { processScheduledNotifications } from '../../features/notifications/jobs/notification-processor.job';
|
||||
import { processAccountPurges } from '../../features/user-profile/jobs/account-purge.job';
|
||||
|
||||
let schedulerInitialized = false;
|
||||
|
||||
@@ -29,8 +30,25 @@ export function initializeScheduler(): void {
|
||||
}
|
||||
});
|
||||
|
||||
// Daily account purge job at 2 AM (GDPR compliance - 30-day grace period)
|
||||
cron.schedule('0 2 * * *', async () => {
|
||||
logger.info('Running account purge job');
|
||||
try {
|
||||
const result = await processAccountPurges();
|
||||
logger.info('Account purge job completed successfully', {
|
||||
processed: result.processed,
|
||||
deleted: result.deleted,
|
||||
errors: result.errors.length,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error('Account purge job failed', {
|
||||
error: error instanceof Error ? error.message : String(error)
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
schedulerInitialized = true;
|
||||
logger.info('Cron scheduler initialized - notification job scheduled for 8 AM daily');
|
||||
logger.info('Cron scheduler initialized - notification job (8 AM) and account purge job (2 AM) scheduled daily');
|
||||
}
|
||||
|
||||
export function isSchedulerInitialized(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user