comparison src/google.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 ccf1d9e741bd
children c552faae9c1c
comparison
equal deleted inserted replaced
16:d2208a4ed5c8 17:a52b5b244e51
47 async.each friends, ((friend, callback) -> 47 async.each friends, ((friend, callback) ->
48 async.waterfall [ 48 async.waterfall [
49 (callback) -> 49 (callback) ->
50 getStream(user, friend, callback) 50 getStream(user, friend, callback)
51 (stream, callback) -> 51 (stream, callback) ->
52 _.each stream.items, (post) -> 52 async.each stream.items, ((post, cb) ->
53 async.waterfall [ 53 async.waterfall [
54 (callback) -> 54 (callback) ->
55 FromESN.search {uid: post.id + "@google_to_" + me, recipientUser: me}, callback 55 FromESN.search {uid: post.id + "@google_to_" + me, recipientUser: me}, callback
56 (result, callback) -> 56 (result, callback) ->
57 return if result.length isnt 0 57 return if result.length isnt 0
74 created: Date.now() 74 created: Date.now()
75 , callback 75 , callback
76 ], (err, result) -> 76 ], (err, result) ->
77 #console.log err 77 #console.log err
78 #console.log result 78 #console.log result
79 return 79 cb()
80 callback null, null 80 ), (err) ->
81 callback null, 'done'
81 ], (err, result) -> 82 ], (err, result) ->
82 #console.log 'done.' 83 #console.log 'done.'
83 callback null, 'done' 84 callback null, 'done'
84 ), (err) -> 85 ), (err) ->
85 if err 86 if err
86 console.log 'one post fail to process' 87 console.log 'one post fail to process'
87 else 88 else
88 console.log 'all google friends processed' 89 console.log 'all google friends processed'
89 return
90 return 90 return
91 91
92 92
93 ####################################### 93 #######################################
94 ###### get user info googleplus ###### 94 ###### get user info googleplus ######
144 data +=chunk 144 data +=chunk
145 145
146 res.on "end", () -> 146 res.on "end", () ->
147 async.waterfall [ 147 async.waterfall [
148 (callback) -> 148 (callback) ->
149 users = JSON.parse(decodeURI(data)) 149 try
150 return if (users.error?) 150 users = JSON.parse(decodeURI(data))
151 callback null,users 151 return if (users.error?)
152 callback null,users
153 catch err
154 console.log 'getFriends error'
155 return
152 (users, callback) -> 156 (users, callback) ->
153 EdgeControl.removeEdges(me,'@google') 157 EdgeControl.removeEdges(me,'@google')
154 _.each users.items, (user) -> 158 async.each users.items, ((user, cb) ->
155 if user.id? 159 if user.id?
156 friends.push(user.id) 160 friends.push(user.id)
157 Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url) 161 Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url)
158 EdgeControl.addEdge(me,user.id+'@google') 162 EdgeControl.addEdge(me,user.id+'@google')
159 callback null, friends 163 ), (err) ->
164 callback null, friends
160 ], (err, friends) -> 165 ], (err, friends) ->
161 callback null, friends 166 callback null, friends
162 return 167 return
163 168
164 ).on "error", (e) -> 169 ).on "error", (e) ->
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)