diff options
author | rhenium <rhenium@rhe.jp> | 2014-06-29 08:06:37 +0900 |
---|---|---|
committer | rhenium <rhenium@rhe.jp> | 2014-06-29 08:06:37 +0900 |
commit | 521fd5e6597c8c71ebf4e3e9bb277480c6e23f76 (patch) | |
tree | 796edfb21347a590916463768ef3ad9c6146c59d /lib | |
parent | ac9050e1b9e92d1e3d16f2268f4e73f6d7f7cc05 (diff) | |
download | aclog-521fd5e6597c8c71ebf4e3e9bb277480c6e23f76.tar.gz |
collector: change account state to revoked when recieved unauthorized
Diffstat (limited to 'lib')
-rw-r--r-- | lib/collector/event_queue.rb | 11 | ||||
-rw-r--r-- | lib/collector/node_connection.rb | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/collector/event_queue.rb b/lib/collector/event_queue.rb index 02dba68..bc61373 100644 --- a/lib/collector/event_queue.rb +++ b/lib/collector/event_queue.rb @@ -7,6 +7,7 @@ module Collector @queue_retweet = [] @queue_unfavorite = [] @queue_delete = [] + @queue_unauthorized = [] end def flush @@ -16,6 +17,7 @@ module Collector queue_retweet = @queue_retweet; @queue_retweet = [] queue_unfavorite = @queue_unfavorite; @queue_unfavorite = [] queue_delete = @queue_delete; @queue_delete = [] + queue_unauthorized = @queue_unauthorized; @queue_unauthorized = [] User.create_or_update_bulk_from_json(queue_user.values) Tweet.create_bulk_from_json(queue_tweet.values) @@ -33,6 +35,11 @@ module Collector user_id: event[:target_object][:user][:id], favorites_count: event[:target_object][:favorite_count]) end + + queue_unauthorized.each do |a| + account = Account.find(a[:id]) + account.verify_token! + end end def push_user(user) @@ -74,6 +81,10 @@ module Collector end end + def push_unauthorized(unauthorized) + @queue_unauthorized << unauthorized + end + private def caching(type, unique_key) @_cache ||= {} diff --git a/lib/collector/node_connection.rb b/lib/collector/node_connection.rb index 83cde04..f3da06f 100644 --- a/lib/collector/node_connection.rb +++ b/lib/collector/node_connection.rb @@ -70,6 +70,7 @@ module Collector case msg[:title] when "unauthorized" log(:info, "Received unauthorized: ##{msg[:id]}/#{msg[:user_id]}") + @queue.push_unauthorized(msg) when "tweet" log(:debug, "Received tweet: #{msg[:id]}") @queue.push_tweet(msg) |