Mercurial > pumpbridge
comparison src/pumpio.coffee @ 17:a52b5b244e51
removed unnecessary underscore and replaced it with async
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Fri, 13 Jun 2014 15:18:36 +0200 |
parents | 6fd0a307850f |
children | 3e3fa35e3ce2 |
comparison
equal
deleted
inserted
replaced
16:d2208a4ed5c8 | 17:a52b5b244e51 |
---|---|
35 host = JSON.parse(host) | 35 host = JSON.parse(host) |
36 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") | 36 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") |
37 oauth.get "https://" + server + "/api/user/"+id, token, secret, callback | 37 oauth.get "https://" + server + "/api/user/"+id, token, secret, callback |
38 ], (err,result) -> | 38 ], (err,result) -> |
39 #console.log 'PUMP BODY:' + result | 39 #console.log 'PUMP BODY:' + result |
40 result = JSON.parse(result) | 40 try |
41 id = result.profile.id.substr(result.profile.id.indexOf(':')+1,result.profile.id.length) | 41 result = JSON.parse(result) |
42 Routes.updateUserDB(id,result.profile.preferredUsername,result.profile.displayName,result.profile.url,result.profile.image.url) | 42 id = result.profile.id.substr(result.profile.id.indexOf(':')+1,result.profile.id.length) |
43 Routes.updateUserDB(id,result.profile.preferredUsername,result.profile.displayName,result.profile.url,result.profile.image.url) | |
44 catch err | |
45 console.log 'pumpio getUser error' + err | |
43 return | 46 return |
44 | 47 |
45 postUser = (bridgeid, to, text, callback) -> | 48 postUser = (bridgeid, to, text, callback) -> |
46 | 49 |
47 bridgename = bridgeid.substr(0,bridgeid.indexOf('@')) | 50 bridgename = bridgeid.substr(0,bridgeid.indexOf('@')) |
99 host = JSON.parse(host) | 102 host = JSON.parse(host) |
100 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") | 103 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") |
101 oauth.get "https://" + server + "/api/user/"+id+"/feed", token, secret, callback | 104 oauth.get "https://" + server + "/api/user/"+id+"/feed", token, secret, callback |
102 ], (err,result) -> | 105 ], (err,result) -> |
103 #console.log 'PUMP BODY:' + result | 106 #console.log 'PUMP BODY:' + result |
104 result = JSON.parse(result) | 107 try |
105 callback null, result | 108 result = JSON.parse(result) |
109 callback null, result | |
110 catch err | |
111 console.log "pump.io Error" | |
112 callback null, null | |
106 return | 113 return |
107 | 114 |
108 ####################################### | 115 ####################################### |
109 ##### get user pumpio note ##### | 116 ##### get user pumpio note ##### |
110 ####################################### | 117 ####################################### |