diff options
author | rhenium <re4k@re4k.info> | 2013-05-19 18:09:03 +0900 |
---|---|---|
committer | rhenium <re4k@re4k.info> | 2013-05-19 18:09:03 +0900 |
commit | a112e1317a957e9bb26aaad7817f06668bef51ab (patch) | |
tree | e0ff31f6c8a0fe85a720a440fd5519cc0767858b | |
parent | 197f1e9a8edf3fb3f797bca0247e8abbd7c8111b (diff) | |
download | aclog-a112e1317a957e9bb26aaad7817f06668bef51ab.tar.gz |
delete -> delete, unfavorite
-rw-r--r-- | collector/stream.rb | 5 | ||||
-rw-r--r-- | lib/aclog/receiver/collector_connection.rb | 20 |
2 files changed, 18 insertions, 7 deletions
diff --git a/collector/stream.rb b/collector/stream.rb index 78afca7..5b3917e 100644 --- a/collector/stream.rb +++ b/collector/stream.rb @@ -156,6 +156,7 @@ module Aclog @callback.call( type: "favorite", tweet_id: target_object[:id], + target_user_id: target[:id], user_id: source[:id] ) log(:debug, "Sent favorite", source[:id] => target_object[:id]) @@ -163,8 +164,9 @@ module Aclog def send_unfavorite(source, target_object) @callback.call( - type: "delete", + type: "unfavorite", tweet_id: target_object[:id], + target_user_id: target[:id], user_id: source[:id] ) log(:debug, "Sent unfavorite", source[:id] => target_object[:id]) @@ -177,6 +179,7 @@ module Aclog type: "retweet", id: status[:id], tweet_id: status[:retweeted_status][:id], + target_user_id: status[:retweeted_status][:user][:id], user_id: status[:user][:id] ) log(:debug, "Sent retweet", status[:user][:id] => status[:retweeted_status][:id]) diff --git a/lib/aclog/receiver/collector_connection.rb b/lib/aclog/receiver/collector_connection.rb index 2d82a58..2a0b24e 100644 --- a/lib/aclog/receiver/collector_connection.rb +++ b/lib/aclog/receiver/collector_connection.rb @@ -67,6 +67,8 @@ module Aclog receive_tweet(msg) when "favorite" receive_favorite(msg) + when "unfavorite" + receive_unfavorite(msg) when "retweet" receive_retweet(msg) when "delete" @@ -166,6 +168,14 @@ module Aclog end end + def receive_unfavorite(msg) + @@queue.push -> do + Rails.logger.debug("Receive Unfavorite(#{@worker_number}): #{msg["user_id"]} => #{msg["tweet_id"]}") + Favorite.delete_from_hash(:tweet_id => msg["tweet_id"], + :user_id => msg["user_id"]) + end + end + def receive_retweet(msg) @@queue.push -> do Rails.logger.debug("Receive Retweet(#{@worker_number}): #{msg["user_id"]} => #{msg["tweet_id"]}") @@ -176,15 +186,13 @@ module Aclog end def receive_delete(msg) - @@queue.push -> do - if msg["id"] + if msg["id"] + @@queue.push -> do Rails.logger.debug("Receive Delete(#{@worker_number}): #{msg["id"]}") Tweet.delete_from_id(msg["id"]) - elsif msg["tweet_id"] - Rails.logger.debug("Receive Unfavorite(#{@worker_number}): #{msg["user_id"]} => #{msg["tweet_id"]}") - Favorite.delete_from_hash(:tweet_id => msg["tweet_id"], - :user_id => msg["user_id"]) end + elsif msg["tweet_id"] + receive_unfavorite(msg) end end |