2018-07-10 11:02:20 -04:00
|
|
|
import * as Bull from 'bull'
|
2018-01-30 07:27:07 -05:00
|
|
|
import { logger } from '../../../helpers/logger'
|
|
|
|
import { Emailer } from '../../emailer'
|
|
|
|
|
|
|
|
export type EmailPayload = {
|
|
|
|
to: string[]
|
|
|
|
subject: string
|
|
|
|
text: string
|
2019-01-09 09:14:29 -05:00
|
|
|
from?: string
|
2018-01-30 07:27:07 -05:00
|
|
|
}
|
|
|
|
|
2018-07-10 11:02:20 -04:00
|
|
|
async function processEmail (job: Bull.Job) {
|
2018-01-30 07:27:07 -05:00
|
|
|
const payload = job.data as EmailPayload
|
|
|
|
logger.info('Processing email in job %d.', job.id)
|
|
|
|
|
2019-01-09 09:14:29 -05:00
|
|
|
return Emailer.Instance.sendMail(payload.to, payload.subject, payload.text, payload.from)
|
2018-01-30 07:27:07 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
export {
|
|
|
|
processEmail
|
|
|
|
}
|