ffffng/server/jobs/MailQueueJob.ts
baldo 8b8835e4ac Typescript migration:
* Refactoring of scheduler and jobs to use promises.
* Add "failed" state for tasks.
2020-04-08 23:41:04 +02:00

22 lines
651 B
TypeScript

import Logger from "../logger"
import MailService from "../services/mailService"
export default {
name: 'MailQueueJob',
description: 'Send pending emails (up to 5 attempts in case of failures).',
run: (): Promise<void> => {
return new Promise<void>(
(resolve, reject) => {
MailService.sendPendingMails((err: any): void => {
if (err) {
Logger.tag('mail', 'queue').error('Error sending pending mails:', err);
return reject(err);
}
resolve();
});
}
)
}
}