From 29892a96197c6cdb771643f4d16ab9d9dfa2e8dd Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 11 Nov 2015 15:43:25 -0800 Subject: [PATCH] Add user country to contact messages https://app.asana.com/0/54275583589675/64698696631078/f --- app/views/core/ContactModal.coffee | 1 + server/routes/contact.coffee | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/core/ContactModal.coffee b/app/views/core/ContactModal.coffee index 1a7fa17c3..3d8bd01ae 100644 --- a/app/views/core/ContactModal.coffee +++ b/app/views/core/ContactModal.coffee @@ -33,6 +33,7 @@ module.exports = class ContactModal extends ModalView res = tv4.validateMultiple contactMessage, contactSchema return forms.applyErrorsToForm @$el, res.errors unless res.valid @populateBrowserData contactMessage + contactMessage.country = me.get('country') window.tracker?.trackEvent 'Sent Feedback', message: contactMessage sendContactMessage contactMessage, @$el $.post "/db/user/#{me.id}/track/contact_codecombat" diff --git a/server/routes/contact.coffee b/server/routes/contact.coffee index d12fd052a..2afa29980 100644 --- a/server/routes/contact.coffee +++ b/server/routes/contact.coffee @@ -23,6 +23,7 @@ createMailContext = (req, done) -> user = req.user recipientID = req.body.recipientID subject = req.body.subject + country = req.body.country level = if user?.get('points') > 0 then Math.floor(5 * Math.log((1 / 100) * (user.get('points') + 100))) + 1 else 0 premium = user?.isPremium() @@ -30,7 +31,7 @@ createMailContext = (req, done) -> #{message} -- - #{user.get('name') or 'Anonymous'} - Level #{level}#{if premium then ' - Subscriber' else ''} + #{user.get('name') or 'Anonymous'} - Level #{level}#{if premium then ' - Subscriber' else ''}#{if country then ' - ' + country else ''} """ if req.body.browser content += "\n#{req.body.browser} - #{req.body.screenSize}" @@ -46,7 +47,6 @@ createMailContext = (req, done) -> email_data: subject: "[CodeCombat] #{subject ? ('Feedback - ' + (sender or user.get('email')))}" content: content - if recipientID and (user.isAdmin() or ('employer' in (user.get('permissions') ? []))) User.findById(recipientID, 'email').exec (err, document) -> if err