mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-13 22:49:51 -04:00
Merge branch 'master' into production
This commit is contained in:
commit
df0d2e54ee
1 changed files with 10 additions and 10 deletions
|
@ -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')}")
|
Loading…
Reference in a new issue