diff options
author | Rhenium <rhenium@rhe.jp> | 2014-02-28 06:29:16 +0900 |
---|---|---|
committer | Rhenium <rhenium@rhe.jp> | 2014-02-28 06:29:16 +0900 |
commit | b2c328e84d03e73d94938f2f2bf58585feaf9625 (patch) | |
tree | e697a1b1cd65f0f224c8e9dce0b06138b898f4ef /lib | |
parent | 8e70230529b7c9a3979bca3479e5043a0773912e (diff) | |
download | aclog-b2c328e84d03e73d94938f2f2bf58585feaf9625.tar.gz |
refactor collector-receiver
Diffstat (limited to 'lib')
-rw-r--r-- | lib/aclog/receiver/collector_connection.rb | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lib/aclog/receiver/collector_connection.rb b/lib/aclog/receiver/collector_connection.rb index c1258de..9a6128f 100644 --- a/lib/aclog/receiver/collector_connection.rb +++ b/lib/aclog/receiver/collector_connection.rb @@ -62,30 +62,28 @@ module Aclog when "tweet" @channel << -> { log(:debug, "receive tweet: #{msg[:id]}") - Tweet.from_json(msg) + Tweet.create_from_json(msg) } when "favorite" @channel << -> { log(:debug, "receive favorite: #{msg[:source][:id]} => #{msg[:target_object][:id]}") - if f = Favorite.from_json(msg) - f.tweet.notify_favorite - end + f = Favorite.create_from_json(msg) + Notification.notify_favorites_count(f.tweet) } when "unfavorite" @channel << -> { log(:debug, "receive unfavorite: #{msg[:source][:id]} => #{msg[:target_object][:id]}") - Favorite.where(user_id: msg[:source][:id], tweet_id: msg[:target_object][:id]).destroy_all + Favorite.destroy_from_json(msg) } when "retweet" @channel << -> { log(:debug, "receive retweet: #{msg[:user][:id]} => #{msg[:retweeted_status][:id]}") - Retweet.from_json(msg) + Retweet.create_from_json(msg) } when "delete" @channel << -> { - log(:debug, "receive delete: #{msg[:id]}") - Tweet.where(id: msg[:id]).destroy_all - Retweet.where(id: msg[:id]).destroy_all + log(:debug, "receive delete: #{msg[:delete][:status][:id]}") + Tweet.destroy_from_json(msg) || Retweet.destroy_from_json(msg) } when "quit" log(:info, "receive quit: #{msg[:reason]}") |