Mercurial > pumpbridge
diff src/syncALONE.coffee @ 22:b90e6df48d2d
eachLimit instead of each
author | Mathias Gebbe <mgebbe@intevation.de> |
---|---|
date | Mon, 16 Jun 2014 17:31:05 +0200 |
parents | dbe2232af20f |
children | f27ddfa42e94 |
line wrap: on
line diff
--- a/src/syncALONE.coffee Fri Jun 13 21:21:41 2014 +0200 +++ b/src/syncALONE.coffee Mon Jun 16 17:31:05 2014 +0200 @@ -40,7 +40,8 @@ Usermap.scan ((user) -> if user.id.indexOf('@twitter') isnt -1 console.log "start sync for twitter user" - Twitter.sync(user) + Twitter.syncToESN(user) + Twitter.syncFromESN(user) ), (err) -> catch err console.log 'Error!' + err @@ -58,65 +59,6 @@ return -postParser = (post, user, network, callback) -> - parsed = "" - #console.log "\n" + post.id + "\n" + user.id + user.displayName - #PROFILE_LINK PROFILE_NAME PROFILE_PIC_LINK_80x80=$3 POST_LINK POST_TIME CONTENT - #text='<img src='$PROFILE_PIC_LINK_80x80'></img> <a href='$PROFILE_LINK'>'$PROFILE_NAME'</a> <a href='$POST_LINK'>wrotes</a> at '$POST_TIME':<br><br>'$CONTENT'' - - if network is 'facebook' - if user? and user.profilePicLink? - profilePicLink = user.profilePicLink.replace("50x50", "80x80") - else - profilePicLink = 'http://upload.wikimedia.org/wikipedia/commons/thumb/c/c2/F_icon.svg/80px-F_icon.svg.png' - - if post.type is 'status' - parsed = "<img src='" + profilePicLink + "'></img> <a href='" + user.profileLink + "'>" + user.displayName + "</a> <a href='https://www.facebook.com/" + post.id + "'> wrotes</a> via " + network + " at " + post.updated_time + ":<br><br>" + post.message - - if post.type is 'photo' - parsed = "<img src='" + profilePicLink + "'></img> <a href='" + user.profileLink + "'>" + user.displayName + "</a> <a href='"+ post.link + "'> wrotes</a> via " + network + " at " + post.updated_time + ":<br>" - parsed += "<br>" + post.message if post.message? and post.message isnt "" - parsed += "<br><img src='" + post.picture + "'></img>" - - if post.type is 'link' or post.type is 'video' - parsed = "<img src='" + profilePicLink + "'></img> <a href='" + user.profileLink + "'>" + user.displayName + "</a> <a href='https://www.facebook.com/" + post.id + "'> wrotes</a> via " + network + " at " + post.updated_time + ":<br>" - parsed += "<br>" + post.message if post.message? and post.message isnt "" - parsed += "<br>" + post.description if post.description? - parsed += "<br><a href='" + post.link + "'>"+ post.link + "</a>" if post.link? - parsed += "<br><img src='" + post.picture + "'></img>" if post.picture? - - callback null, parsed - - if network is 'google' - parsed = "<img src='" + post.actor.image.url + "'></img> <a href='" + post.actor.url + "'>" + post.actor.displayName + "</a> <a href='"+ post.object.url + "'> wrotes</a> via " + network + " at " + post.updated + ":<br><br>" + post.object.content - if not post.object.attachments? - _.each post.object.attachments, (attachment) -> - - if attachment.objectType == "photo" - parsed += "<br><img src='" + attachment.image.url + "'></img>" - - if attachment.objectType == "article" - parsed += "<br><a href='" + attachment.url + "'>"+ attachment.displayName + "</a>" - if not attachment.image? - parsed += "<br><img src='" + attachment.image.url + "'></img>" - - if attachment.objectType == "video" - parsed += "<br><a href='" + attachment.url + "'>"+ attachment.displayName + "</a>" - if not attachment.image? - parsed += "<br><img src='" + attachment.image.url + "'></img>" - - callback null, parsed - - if network is 'twitter' - - parsed = "<img src='" + post.user.profile_image_url + "'></img> <a href='https://twitter.com/account/redirect_by_id/" + post.user.id + "'>" + post.user.name + "</a> <a href='https://twitter.com/" + post.user.screen_name + "/status/" + post.id_str + "'> wrotes </a> via " + network + " at " + post.created_at + ":<br><br>" + post.text - _.each post.entities.media, (attachment) -> - parsed += "<br><img src='" + attachment.media_url + "'></img>" - callback null, parsed - - return - - sync = () -> # Do this every xx minutes @@ -124,7 +66,7 @@ interval = config.interval if not (interval?) interval = 15 * 60 * 1000 # 900 000 ms (15min) - + async.waterfall [ (callback) -> db.connect(config.params, callback) @@ -135,6 +77,3 @@ return sync() - -exports.postParser = postParser -exports.sync = sync