aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/lib/job-queue/handlers/email.ts
blob: 220d0af32e80ecd62b61f7f5e8da58e234b40439 (plain) (tree)
1
2
3
4
5
6
7
8
9
                            






                                                
               

 
                                             


                                                    
                                                                                           






                                                                              
import * as Bull from 'bull'
import { logger } from '../../../helpers/logger'
import { Emailer } from '../../emailer'

export type EmailPayload = {
  to: string[]
  subject: string
  text: string
  from?: string
}

async function processEmail (job: Bull.Job) {
  const payload = job.data as EmailPayload
  logger.info('Processing email in job %d.', job.id)

  return Emailer.Instance.sendMail(payload.to, payload.subject, payload.text, payload.from)
}

// ---------------------------------------------------------------------------

export {
  processEmail
}