comparison 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
comparison
equal deleted inserted replaced
29:34cfa565f565 30:3e3fa35e3ce2
48 fbtoken = req.body.fbtoken 48 fbtoken = req.body.fbtoken
49 fbdelete = req.body.fbdelete 49 fbdelete = req.body.fbdelete
50 50
51 twdelete = req.body.twdelete 51 twdelete = req.body.twdelete
52 52
53 twmode = req.body.twmode
54 if(req.body.twtoesn?) then twtoesn=true else twtoesn=false
55 if(req.body.twfromesn?) then twfromesn=true else twfromesn=false
56
53 # create/update userdb entrys 57 # create/update userdb entrys
54 # SET THE CONNECTION BETWEENS PUMPIO AND ESN-ACCOUNT (facebook or google) 58 # SET THE CONNECTION BETWEENS PUMPIO AND ESN-ACCOUNT (facebook or google)
55 59
56 #### PUMPIO STUFF #### 60 #### PUMPIO STUFF ####
57 if not (pumpid?) 61 if not (pumpid?)
101 # get the long lived token from facebook 105 # get the long lived token from facebook
102 Facebook.getLongLivedToken fbtoken,(token) -> 106 Facebook.getLongLivedToken fbtoken,(token) ->
103 if (token?) 107 if (token?)
104 saveUsermap(pumpid,fbid,token,fbtoken, (err, result) -> 108 saveUsermap(pumpid,fbid,token,fbtoken, (err, result) ->
105 console.log 'fbsave.') 109 console.log 'fbsave.')
110
111 #### Twitter MODUS ###
112 if (twmode?)
113 console.log "mod tw account"
114 async.waterfall [
115 (callback) ->
116 Usermap.search {user_pumpio: twmode}, callback
117 (result, callback) ->
118 _.each result, (um) ->
119 if um.user_ESN.indexOf('@twitter') isnt -1
120 saveUsermapSelect(um.user_pumpio, um.user_ESN, um.oauth_token, um.extra_token,twfromesn,twtoesn,callback)
121 return
122 ], (err, result) ->
106 123
107 if (fbdelete?) 124 if (fbdelete?)
108 console.log "delete fb account" 125 console.log "delete fb account"
109 async.waterfall [ 126 async.waterfall [
110 (callback) -> 127 (callback) ->
154 created : Date.now() 171 created : Date.now()
155 ) 172 )
156 saveMap.save (cb) -> 173 saveMap.save (cb) ->
157 #console.log 'saved.' 174 #console.log 'saved.'
158 callback null, saveMap 175 callback null, saveMap
176 return
177
178 # update or create usermap
179 saveUsermapSelect = (pumpid, esnid, esntoken, extra, fromesn, toesn, callback) ->
180 saveMap = new Usermap(
181 id : Usermap.key(pumpid,esnid)
182 user_pumpio : pumpid
183 user_ESN : esnid
184 oauth_token : esntoken
185 extra_token : extra
186 fromesn : fromesn
187 toesn: toesn
188 created : Date.now()
189 )
190 saveMap.save (cb) ->
191 #console.log 'saved.'
192 callback null, saveMap
193 return
194
159 195
160 # only create and not update usermap 196 # only create and not update usermap
161 createUsermap = (pumpid,esnid,esntoken) -> 197 createUsermap = (pumpid,esnid,esntoken) ->
162 async.waterfall [(callback) -> 198 async.waterfall [(callback) ->
163 Usermap.create 199 Usermap.create
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)