aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/email.ts
blob: 2ba39a156d805e8e0c1af2c6925410613c80f70b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as Bull from 'bull'
import { logger } from '../../../helpers/logger'
import { Emailer } from '../../emailer'

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

  fromDisplayName?: string
  replyTo?: 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)
}

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

export {
  processEmail
}