8b8835e4ac
* Refactoring of scheduler and jobs to use promises. * Add "failed" state for tasks.
22 lines
651 B
TypeScript
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();
|
|
});
|
|
}
|
|
)
|
|
}
|
|
}
|