Mercurial > pumpbridge
diff src/routes.coffee @ 30:3e3fa35e3ce2
twitter sync likes, recommend mongodb
configure pump2twitter, twitter2pump in webui
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Thu, 28 Aug 2014 18:40:39 +0200 |
parents | a52b5b244e51 |
children | 8238d312e281 |
line wrap: on
line diff
--- a/src/routes.coffee Tue Jul 29 16:06:05 2014 +0200 +++ b/src/routes.coffee Thu Aug 28 18:40:39 2014 +0200 @@ -50,6 +50,10 @@ twdelete = req.body.twdelete + twmode = req.body.twmode + if(req.body.twtoesn?) then twtoesn=true else twtoesn=false + if(req.body.twfromesn?) then twfromesn=true else twfromesn=false + # create/update userdb entrys # SET THE CONNECTION BETWEENS PUMPIO AND ESN-ACCOUNT (facebook or google) @@ -104,6 +108,19 @@ saveUsermap(pumpid,fbid,token,fbtoken, (err, result) -> console.log 'fbsave.') + #### Twitter MODUS ### + if (twmode?) + console.log "mod tw account" + async.waterfall [ + (callback) -> + Usermap.search {user_pumpio: twmode}, callback + (result, callback) -> + _.each result, (um) -> + if um.user_ESN.indexOf('@twitter') isnt -1 + saveUsermapSelect(um.user_pumpio, um.user_ESN, um.oauth_token, um.extra_token,twfromesn,twtoesn,callback) + return + ], (err, result) -> + if (fbdelete?) console.log "delete fb account" async.waterfall [ @@ -156,6 +173,25 @@ saveMap.save (cb) -> #console.log 'saved.' callback null, saveMap + return + +# update or create usermap +saveUsermapSelect = (pumpid, esnid, esntoken, extra, fromesn, toesn, callback) -> + saveMap = new Usermap( + id : Usermap.key(pumpid,esnid) + user_pumpio : pumpid + user_ESN : esnid + oauth_token : esntoken + extra_token : extra + fromesn : fromesn + toesn: toesn + created : Date.now() + ) + saveMap.save (cb) -> + #console.log 'saved.' + callback null, saveMap + return + # only create and not update usermap createUsermap = (pumpid,esnid,esntoken) ->