diff src/google.coffee @ 18:c552faae9c1c

removed unnecessary parts, fixed getFriends async.each
author Mathias Gebbe <mgebbe@intevation.de>
date Fri, 13 Jun 2014 16:37:20 +0200
parents a52b5b244e51
children 6b3f38af3fa4
line wrap: on
line diff
--- a/src/google.coffee	Fri Jun 13 15:18:36 2014 +0200
+++ b/src/google.coffee	Fri Jun 13 16:37:20 2014 +0200
@@ -40,7 +40,7 @@
       updateToken(user,callback)
     (updateuser,callback) ->
       user = updateuser
-      getUser(user)
+      #getUser(user)
       getFriends(user,callback)
   ], (err, friends) ->
     # für jeden Freunde tue dies: hier bewusst von  async.eachSeries friends, ((friend, callback) -> auf async.each gewechselt
@@ -49,6 +49,7 @@
         (callback) ->
           getStream(user, friend, callback)
         (stream, callback) ->
+          return if not stream?
           async.each stream.items, ((post, cb) ->
             async.waterfall [
               (callback) ->
@@ -77,6 +78,7 @@
                  #console.log err
                  #console.log result
                  cb()
+                 return
           ), (err) ->
             callback null, 'done'
       ], (err,  result) ->
@@ -87,6 +89,7 @@
         console.log 'one post fail to process'
       else
         console.log 'all google friends processed'
+        return
   return
 
 
@@ -146,22 +149,19 @@
     res.on "end", () ->
       async.waterfall [
         (callback) ->
-          try
-            users = JSON.parse(decodeURI(data))
-            return if (users.error?)
-            callback null,users
-          catch err
-            console.log 'getFriends error'
-            return
+          users = JSON.parse(decodeURI(data))
+          return if (users.error?)
+          callback null,users
         (users, callback) ->
-          EdgeControl.removeEdges(me,'@google')
-          async.each users.items, ((user, cb) ->
+          #EdgeControl.removeEdges(me,'@google')
+          async.each users.items, ((user,cb) ->
             if user.id?
               friends.push(user.id)
-              Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url)
-              EdgeControl.addEdge(me,user.id+'@google')
-          ), (err) ->
-            callback null, friends
+              #Routes.updateUserDB(user.id+'@google',user.displayName,user.displayName,user.url,user.image.url)
+              #EdgeControl.addEdge(me,user.id+'@google')
+              cb()
+            ), (err) ->
+              callback null, friends
       ], (err, friends) ->
         callback null, friends
        return
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)