Mercurial > rsstweet
comparison app/models/tweet.rb @ 161:c2e9d3a36bde
Improved id check
author | nanaya <me@nanaya.pro> |
---|---|
date | Fri, 03 Aug 2018 02:01:32 +0900 |
parents | 4e4195e60c2b |
children | ed73d92c7113 |
comparison
equal
deleted
inserted
replaced
160:4e4195e60c2b | 161:c2e9d3a36bde |
---|---|
10 (15 + rand(15)).minutes | 10 (15 + rand(15)).minutes |
11 end | 11 end |
12 | 12 |
13 def initialize(twitter_id) | 13 def initialize(twitter_id) |
14 @clients = {} | 14 @clients = {} |
15 @twitter_id = twitter_id | 15 @twitter_id = twitter_id.to_s |
16 end | 16 end |
17 | 17 |
18 def id | 18 def id |
19 user.id | 19 user.id |
20 end | 20 end |
50 raw = Rails.cache.fetch("user:v1:#{@twitter_id}", :expires_in => self.class.cache_expires_time) do | 50 raw = Rails.cache.fetch("user:v1:#{@twitter_id}", :expires_in => self.class.cache_expires_time) do |
51 client_try(:user, @twitter_id).tap do |data| | 51 client_try(:user, @twitter_id).tap do |data| |
52 if data[:result] == :ok | 52 if data[:result] == :ok |
53 user = data[:data] | 53 user = data[:data] |
54 | 54 |
55 if user.id != @twitter_id || user.screen_name != @twitter_id | 55 if user.id_str != @twitter_id || user.screen_name != @twitter_id |
56 throw "Wrong user data. Requested: #{@twitter_id}, got: #{user.id} (#{user.screen_name.printable})" | 56 throw "Wrong user data. Requested: #{@twitter_id}, got: #{user.id} (#{user.screen_name.printable})" |
57 end | 57 end |
58 end | 58 end |
59 end | 59 end |
60 end | 60 end |