comparison src/facebook.coffee @ 22:b90e6df48d2d

eachLimit instead of each
author Mathias Gebbe <mgebbe@intevation.de>
date Mon, 16 Jun 2014 17:31:05 +0200
parents a52b5b244e51
children 08d9679da0f7
comparison
equal deleted inserted replaced
21:dbe2232af20f 22:b90e6df48d2d
46 getUser(user) 46 getUser(user)
47 getStream user,callback 47 getStream user,callback
48 ], (err, posts) -> 48 ], (err, posts) ->
49 return if not posts? or posts.length is 0 49 return if not posts? or posts.length is 0
50 #console.log JSON.stringify(posts) # all posts from network (100) 50 #console.log JSON.stringify(posts) # all posts from network (100)
51 async.eachSeries posts, ((post, callback) -> 51 async.eachLimit posts, 10, ((post, callback) ->
52 async.waterfall [ 52 async.waterfall [
53 (callback) -> 53 (callback) ->
54 FromESN.search {uid: post.id + "@facebook_to_" + me, recipientUser: me}, callback 54 FromESN.search {uid: post.id + "@facebook_to_" + me}, callback
55 (result, callback) -> 55 (result, callback) ->
56 return if result.length isnt 0 or post.from.id is id 56 return if result.length isnt 0 or post.from.id is id
57 #console.log "postid: " + post.from.id + "id:" + id 57 #console.log "postid: " + post.from.id + "id:" + id
58 # if this is your own post return!!! 58 # if this is your own post return!!!
59 getPublicUserInfo(post.from.id , callback) 59 getPublicUserInfo(post.from.id , callback)
85 if err 85 if err
86 console.log 'one post fail to process' 86 console.log 'one post fail to process'
87 else 87 else
88 console.log 'all posts processed' 88 console.log 'all posts processed'
89 return 89 return
90
90 #### 91 ####
91 # TO DO: GET NEW COMMENTS 92 # TO DO: GET NEW COMMENTS
92 # for each fromESN check the comments 93 # for each fromESN check the comments
93 # if comment author = me 94 # if comment author = me
94 # post comment 95 # post comment
96 # post comment with 'user schreibt' 97 # post comment with 'user schreibt'
97 async.waterfall [ 98 async.waterfall [
98 (callback) -> 99 (callback) ->
99 FromESN.search {recipientUser: me}, callback 100 FromESN.search {recipientUser: me}, callback
100 (allESN, callback) -> 101 (allESN, callback) ->
101 async.each allESN, ((fromesn, callback) -> 102 async.eachLimit allESN, 10, ((fromesn, callback) ->
102 async.waterfall [ 103 async.waterfall [
103 (cb) -> 104 (cb) ->
104 if fromesn.sourcePost.indexOf('www.facebook.com') is -1 105 if fromesn.sourcePost.indexOf('www.facebook.com') is -1
105 return 106 return
106 Usermap.search {id: me + '_to_' + me}, cb 107 Usermap.search {id: me + '_to_' + me}, cb
127 ), (err) -> 128 ), (err) ->
128 callback null, 'done' 129 callback null, 'done'
129 ], (err, result) -> 130 ], (err, result) ->
130 #done 131 #done
131 132
132
133 # GET PUBLIC PUMP POSTS AND POST THEM 133 # GET PUBLIC PUMP POSTS AND POST THEM
134 async.waterfall [ 134 async.waterfall [
135 (callback) -> 135 (callback) ->
136 Usermap.search {id: me + '_to_' + me}, callback 136 Usermap.search {id: me + '_to_' + me}, callback
137 (user, callback) -> 137 (user, callback) ->
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)