Mercurial > pumpbridge
diff src/facebook.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 |
line wrap: on
line diff
--- a/src/facebook.coffee Thu Jun 05 18:02:25 2014 +0200 +++ b/src/facebook.coffee Fri Jun 06 10:18:14 2014 +0200 @@ -104,7 +104,7 @@ (pumpuser, cb) -> Pump.getNote(pumpuser[0], fromesn.pumpPost, cb) (note, cb) -> - if note.liked is not undefined and note.liked is true + if note.liked is true obj = fromesn.postid.substr(0,fromesn.postid.indexOf('@')) postLike(user,obj) if (note.replies?) @@ -135,7 +135,7 @@ (feed, callback) -> async.eachSeries feed.items, ((post, callback) -> # do for each post - if (post.verb is "post" or post.verb is "share") and (post.object.objectType is "note" or post.object.objectType is "image") and (Pump.isPublicActivity(post)) and (typeof post.object.deleted is "undefined") + if (post.verb is "post" or post.verb is "share") and (post.object.objectType is "note" or post.object.objectType is "image") and (Pump.isPublicActivity(post)) and not (post.object.deleted?) postStream(user,post) callback null, 'done' ), (err) -> @@ -169,9 +169,9 @@ res.on "end", () -> user = JSON.parse(data) ### with app id ### - Routes.updateUserDB(user.id+'@facebook',user.name,user.name,user.link,user.picture.data.url) unless typeof user is "undefined" + Routes.updateUserDB(user.id+'@facebook',user.name,user.name,user.link,user.picture.data.url) if user? ### with link ### - Routes.updateUserDB(user.link,user.name,user.name,user.link,user.picture.data.url) unless typeof user is "undefined" + Routes.updateUserDB(user.link,user.name,user.name,user.link,user.picture.data.url) if user? return ).on "error", (e) -> @@ -199,7 +199,7 @@ return _.each res.data, (user) -> - getUserById(me,user.uid2,token) unless typeof user.id is "undefined" + getUserById(me,user.uid2,token) if user.id? return return @@ -224,7 +224,7 @@ console.log (if not res then "error occurred" else res.error) _.each res.data, (page) -> - getUserById(me,page.id,token) unless typeof user.id is "undefined" + getUserById(me,page.id,token) if user.id? return @@ -274,8 +274,8 @@ FB.setAccessToken token - return if typeof post.object.content is "undefined" or post.object.content is "" - ToESN.search {uid: post.object.id + "@twitter"}, (err, result) -> + return if not post.object.content? or post.object.content is "" + ToESN.search {uid: post.object.id + "@facebook"}, (err, result) -> if result.length is 0 body = post.object.content.replace(/<(?:.|\n)*?>/gm, '') + " " + post.object.url @@ -289,7 +289,7 @@ async.waterfall [ (callback) -> savePost = new ToESN() - savePost.uid = post.object.id + "@twitter" + savePost.uid = post.object.id + "@facebook" savePost.sourceUser = post.actor.id savePost.sourcePost = post.object.id savePost.targetUser = user.user_ESN @@ -372,16 +372,15 @@ return res.on "end", () -> - user = JSON.parse(data) unless data isnt "undefined" + user = JSON.parse(data) if data? #### with app user id ### - Routes.updateUserDB(user.id+'@facebook',user.name,user.name,user.link,user.picture.data.url) unless typeof user is "undefined" - EdgeControl.addEdge(me,user.id+'@facebook') unless typeof user is "undefined" - - #### with profile url ### - Routes.updateUserDB(user.link,user.name,user.name,user.link,user.picture.data.url) unless typeof user is "undefined" - EdgeControl.addEdge(me,user.link) unless typeof user is "undefined" - + if user? + Routes.updateUserDB(user.id+'@facebook',user.name,user.name,user.link,user.picture.data.url) + EdgeControl.addEdge(me,user.id+'@facebook') + #### with profile url ### + Routes.updateUserDB(user.link,user.name,user.name,user.link,user.picture.data.url) + EdgeControl.addEdge(me,user.link) return