Mercurial > pumpbridge
comparison src/google.coffee @ 4:f352c74a6a5b
remove typeof, corrected facebooks toESN entrys
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Fri, 06 Jun 2014 10:18:14 +0200 |
parents | 98a070c98982 |
children | 2123f355ab68 |
comparison
equal
deleted
inserted
replaced
3:98a070c98982 | 4:f352c74a6a5b |
---|---|
101 data += chunk | 101 data += chunk |
102 return | 102 return |
103 | 103 |
104 res.on "end", () -> | 104 res.on "end", () -> |
105 user = JSON.parse(data) | 105 user = JSON.parse(data) |
106 Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url) unless typeof user.id is "undefined" | 106 Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url) if user.id? |
107 | 107 |
108 ).on "error", (e) -> | 108 ).on "error", (e) -> |
109 console.log "Got error: " + e.message | 109 console.log "Got error: " + e.message |
110 return | 110 return |
111 return | 111 return |
113 | 113 |
114 ####################################### | 114 ####################################### |
115 ###### get google friends ###### | 115 ###### get google friends ###### |
116 ####################################### | 116 ####################################### |
117 getFriends = (user, callback) -> | 117 getFriends = (user, callback) -> |
118 return if typeof user is "undefined" | 118 return if not user? |
119 data = "" | 119 data = "" |
120 friends = new Array() | 120 friends = new Array() |
121 me = user.user_pumpio | 121 me = user.user_pumpio |
122 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) | 122 id = user.user_ESN.substr(0,user.user_ESN.indexOf('@')) |
123 if user.oauth_token.indexOf(';') isnt -1 | 123 if user.oauth_token.indexOf(';') isnt -1 |
143 return if (users.error?) | 143 return if (users.error?) |
144 callback null,users | 144 callback null,users |
145 (users, callback) -> | 145 (users, callback) -> |
146 EdgeControl.removeEdges(me,'@google') | 146 EdgeControl.removeEdges(me,'@google') |
147 _.each users.items, (user) -> | 147 _.each users.items, (user) -> |
148 friends.push(user.id) | 148 if user.id? |
149 Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url) unless typeof user.id is "undefined" | 149 friends.push(user.id) |
150 EdgeControl.addEdge(me,user.id+'@google') unless typeof user.id is "undefined" | 150 Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url) |
151 EdgeControl.addEdge(me,user.id+'@google') | |
151 callback null, friends | 152 callback null, friends |
152 ], (err, friends) -> | 153 ], (err, friends) -> |
153 callback null, friends | 154 callback null, friends |
154 return | 155 return |
155 | 156 |