   user.set 'mailChimp.email', post.data.email
   user.set 'mailChimp.euid', post.data.id
 
-#  badLog("Updating user object to: #{JSON.stringify(user.toObject(), null, '\t')}")
 
 module.exports.handleUnsubscribe = handleUnsubscribe = (user) ->
   user.set 'emailSubscriptions', []
   for emailGroup in mail.NEWS_GROUPS
     user.setEmailSubscription emailGroup, false
-
-#  badLog("Unsubscribing user object to: #{JSON.stringify(user.toObject(), null, '\t')}")

mail = require '../commons/mail'
User = require '../users/User'
errors = require '../commons/errors'
#request = require 'request'
config = require '../../server_config'
LevelSession = require '../levels/sessions/LevelSession'
Level = require '../levels/Level'
log = require 'winston'
sendwithus = require '../sendwithus'

#badLog = (text) ->
#  console.log text
#  request.post 'http://requestb.in/1brdpaz1', { form: {log: text} }

module.exports.setup = (app) ->
  app.all config.mail.mailchimpWebhook, handleMailchimpWebHook


handleMailchimpWebHook = (req, res) ->
  post = req.body

  unless post.type in ['unsubscribe', 'profile']
    res.send 'Bad post type'
