comparison src/pumpio.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
138 else 138 else
139 result = JSON.parse(result) 139 result = JSON.parse(result)
140 callback null, result 140 callback null, result
141 return 141 return
142 142
143 getLikes = (user, callback) ->
144 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@'))
145 server = user.user_ESN.substr(user.user_ESN.indexOf('@')+1,user.user_ESN.length)
146 token = user.oauth_token.substr(0,user.oauth_token.indexOf(';'))
147 secret = user.oauth_token.substr(user.oauth_token.indexOf(';')+1,user.oauth_token.length)
148 # https://io.intevation.de/api/user/mgebbe/favorites
149 url = "https://" + server + "/api/user/" + id + "/favorites"
150 # get tokens and ask pump.io api for userinformation then update userdb
151 async.waterfall [
152 (callback) ->
153 Host.search {hostname: server}, callback
154 (host,callback) ->
155 # get host from db
156 host = JSON.stringify(host)
157 host = JSON.parse(host)
158 #console.log JSON.stringify host
159 oauth = new OAuth.OAuth(host[0].request_token_endpoint, host[0].access_token_endpoint, host[0].client_id, host[0].client_secret, "1.0A", null, "HMAC-SHA1")
160 oauth.get url, token, secret, callback
161 ], (err,result) ->
162 if err
163 callback null, null
164 else
165 callback null, (result)
166 return
167
168
169
143 isPublicActivity = (act) -> 170 isPublicActivity = (act) ->
144 recip = [] 171 recip = []
145 _.each [ 172 _.each [
146 "to" 173 "to"
147 "cc" 174 "cc"
157 184
158 exports.isPublicActivity = isPublicActivity 185 exports.isPublicActivity = isPublicActivity
159 exports.getUserFeed = getUserFeed 186 exports.getUserFeed = getUserFeed
160 exports.getUser = getUser 187 exports.getUser = getUser
161 exports.getNote = getNote 188 exports.getNote = getNote
189 exports.getLikes = getLikes
162 exports.postUser = postUser 190 exports.postUser = postUser
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)