diff --git a/server/routes/contact.coffee b/server/routes/contact.coffee index 189f0774a..c1b6cf132 100644 --- a/server/routes/contact.coffee +++ b/server/routes/contact.coffee @@ -27,19 +27,24 @@ createMailContext = (req, done) -> level = if user?.get('points') > 0 then Math.floor(5 * Math.log((1 / 100) * (user.get('points') + 100))) + 1 else 0 premium = user?.isPremium() + teacher = user?.isTeacher() content = """ #{message} -- - #{user.get('name') or 'Anonymous'} - Level #{level}#{if premium then ' - Subscriber' else ''}#{if country then ' - ' + country else ''} + #{user.get('name') or 'Anonymous'} - Level #{level}#{if teacher then ' - Teacher' else ''}#{if premium then ' - Subscriber' else ''}#{if country then ' - ' + country else ''} """ if req.body.browser content += "\n#{req.body.browser} - #{req.body.screenSize}" + address = switch + when teacher then config.mail.supportSchools + when premium then config.mail.supportPremium + else config.mail.supportPrimary context = email_id: sendwithus.templates.plain_text_email recipient: - address: if premium then config.mail.supportPremium else config.mail.supportPrimary + address: address sender: address: config.mail.username reply_to: sender or user.get('email') diff --git a/server_config.coffee b/server_config.coffee index 68a752e68..6f6eaf7ee 100644 --- a/server_config.coffee +++ b/server_config.coffee @@ -55,6 +55,7 @@ config.mail = username: process.env.COCO_MAIL_SERVICE_USERNAME or '' supportPrimary: process.env.COCO_MAIL_SUPPORT_PRIMARY or '' supportPremium: process.env.COCO_MAIL_SUPPORT_PREMIUM or '' + supportSchools: process.env.COCO_MAIL_SUPPORT_SCHOOLS or '' mailchimpAPIKey: process.env.COCO_MAILCHIMP_API_KEY or '' mailchimpWebhook: process.env.COCO_MAILCHIMP_WEBHOOK or '/mail/webhook' sendwithusAPIKey: process.env.COCO_SENDWITHUS_API_KEY or ''