Merge branch 'master' into production

This commit is contained in:
Scott Erickson 2014-01-24 12:39:18 -08:00
commit df0d2e54ee

View file

@ -16,22 +16,22 @@ module.exports.setupRoutes = (app) ->
badLog("Bad post type: #{post.type}")
return res.end()
unless post['data[email]']
unless post.data.email
badLog("Ignoring because no email: #{JSON.stringify(req.body, null, '\t')}")
return res.end()
unless post['data[email]'] is 'sderickson@gmail.com'
unless post.data.email is 'sderickson@gmail.com'
badLog("Ignoring because this is a test: #{JSON.stringify(req.body, null, '\t')}")
return res.end()
User.findOne {'mailChimp.euid':post['data[id]']}, (err, user) ->
User.findOne {'mailChimp.euid':post.data.id}, (err, user) ->
return errors.serverError(res) if err
if not user
badLog("could not find user for...: #{{'mailChimp.euid':post['data[id]']}}")
badLog("could not find user for...: #{{'mailChimp.euid':post.data.id}}")
return res.end()
handleProfileUpdate(post, user) if post.type is 'profile'
handleUnsubscribe(post, user) if post.type is 'unsubscribe'
handleProfileUpdate(user, post) if post.type is 'profile'
handleUnsubscribe(user) if post.type is 'unsubscribe'
res.end()
user.updatedMailChimp = true # so as not to echo back to mailchimp
@ -40,18 +40,18 @@ module.exports.setupRoutes = (app) ->
res.end()
handleProfileUpdate = (data, user) ->
groups = data['data[merges][INTERESTS]'].split(', ')
handleProfileUpdate = (user, post) ->
groups = post.data.merges.INTERESTS.split(', ')
groups = (map[g] for g in groups when map[g])
user.set 'emailSubscriptions', groups
mailChimpInfo = user.get 'mailChimp'
mailChimpInfo.email = data['data[email]']
mailChimpInfo.email = post.data.email
user.set 'mailChimp', mailChimpInfo
badLog("Updating user object to: #{JSON.stringify(user.toObject(), null, '\t')}")
handleUnsubscribe = (data, user) ->
handleUnsubscribe = (user) ->
user.set 'emailSubscriptions', []
badLog("Unsubscribing user object to: #{JSON.stringify(user.toObject(), null, '\t')}")