<commit_before>settings = require("settings-sharelatex")
EmailBuilder = require "./EmailBuilder"
EmailSender = require "./EmailSender"

module.exports =

	sendEmail : (emailType, opts, callback = (err)->)->
		email = EmailBuilder.buildEmail emailType, opts
		if email.type == "lifecycle" and !settings.email.lifecycle
			return callback()
		opts.html = email.html
		opts.subject = email.subject
		EmailSender.sendEmail opts, (err)->
			callback(err)<commit_msg>added null check for email property #ugly<commit_after>settings = require("settings-sharelatex")
EmailBuilder = require "./EmailBuilder"
EmailSender = require "./EmailSender"

if !settings.email?
	settings.email = 
		lifecycleEnabled:false


module.exports =

	sendEmail : (emailType, opts, callback = (err)->)->
		email = EmailBuilder.buildEmail emailType, opts
		if email.type == "lifecycle" and !settings.email.lifecycle
			return callback()
		opts.html = email.html
		opts.subject = email.subject
		EmailSender.sendEmail opts, (err)->
			callback(err)
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0, 'mean_word_length': 4.713483146067416, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6886642', 'n_tokens_mistral': 317, 'n_tokens_neox': 292, 'n_words': 75}