Mercurial > pumpbridge
diff src/facebook.coffee @ 8:6fd0a307850f
check empty strings and users
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Wed, 11 Jun 2014 21:58:41 +0200 |
parents | 2123f355ab68 |
children | ccf1d9e741bd |
line wrap: on
line diff
--- a/src/facebook.coffee Wed Jun 11 02:32:53 2014 +0200 +++ b/src/facebook.coffee Wed Jun 11 21:58:41 2014 +0200 @@ -49,7 +49,6 @@ return if not (posts?) or posts.length is 0 #console.log JSON.stringify(posts) # all posts from network (100) async.eachSeries posts, ((post, callback) -> - async.waterfall [ (callback) -> FromESN.search {uid: post.id + "@facebook_to_" + me, recipientUser: me}, callback @@ -62,7 +61,10 @@ pubuser = pubuser User.search {id: pubuser.id + "@facebook"}, callback (dbuser, callback) -> - Sync.postParser post, dbuser[0], 'facebook', callback + if (dbuser[0]?) + Sync.postParser post, dbuser[0], 'facebook', callback + else + return (parsed, callback) -> Pump.postUser bridgeid, me, parsed, callback (pumppost, callback) -> @@ -103,11 +105,13 @@ async.each allESN, ((fromesn, callback) -> async.waterfall [ (cb) -> - cb (true) if fromesn.sourcePost.indexOf('www.facebook.com') is -1 + if fromesn.sourcePost.indexOf('www.facebook.com') is -1 + return Usermap.search {id: me + '_to_' + me}, cb (pumpuser, cb) -> Pump.getNote(pumpuser[0], fromesn.pumpPost, cb) (note, cb) -> + return if not (note?) if note.liked is true obj = fromesn.postid.substr(0,fromesn.postid.indexOf('@')) postLike(user,obj) @@ -224,7 +228,7 @@ FB.setAccessToken token - FB.api "me/likes?limit=1000&", + FB.api "me/likes", fields: [ "id" ] @@ -409,7 +413,6 @@ ###### get user facebook by id and add him to UserDB and EDGES ##### ###################################################################### getPublicUserInfo = (id, callback) -> - FB.api ""+id, (res) -> if not res or res.error