2014-03-05 06:22:52 -05:00
|
|
|
settings = require("settings-sharelatex")
|
|
|
|
EmailBuilder = require "./EmailBuilder"
|
2014-03-04 13:10:06 -05:00
|
|
|
EmailSender = require "./EmailSender"
|
|
|
|
|
2014-03-06 04:51:19 -05:00
|
|
|
if !settings.email?
|
2016-10-03 10:25:38 -04:00
|
|
|
settings.email =
|
2014-03-06 04:51:19 -05:00
|
|
|
lifecycleEnabled:false
|
|
|
|
|
|
|
|
|
2014-03-04 13:10:06 -05:00
|
|
|
module.exports =
|
|
|
|
|
2014-03-05 09:56:52 -05:00
|
|
|
sendEmail : (emailType, opts, callback = (err)->)->
|
2014-03-05 06:22:52 -05:00
|
|
|
email = EmailBuilder.buildEmail emailType, opts
|
|
|
|
if email.type == "lifecycle" and !settings.email.lifecycle
|
|
|
|
return callback()
|
2014-03-04 13:10:06 -05:00
|
|
|
opts.html = email.html
|
2016-10-03 10:25:38 -04:00
|
|
|
opts.text = email.text
|
2014-03-04 13:10:06 -05:00
|
|
|
opts.subject = email.subject
|
|
|
|
EmailSender.sendEmail opts, (err)->
|
2016-10-03 10:25:38 -04:00
|
|
|
callback(err)
|