comparison app/models/tweet.rb @ 156:1abfa910d83e

Don't log, just throw
author nanaya <me@nanaya.pro>
date Sat, 28 Jul 2018 02:46:44 +0900
parents fd7344643903
children 6e6051cd9cca
comparison
equal deleted inserted replaced
155:e78ba80ff83c 156:1abfa910d83e
24 raw = Rails.cache.fetch(cache_key, :expires_in => cache_expires_time) do 24 raw = Rails.cache.fetch(cache_key, :expires_in => cache_expires_time) do
25 client_try(:user_timeline, @twitter_id, TIMELINE_OPTIONS).tap do |data| 25 client_try(:user_timeline, @twitter_id, TIMELINE_OPTIONS).tap do |data|
26 if data[:result] == :ok 26 if data[:result] == :ok
27 if data[:data].any? && data[:data].first.user.id != @twitter_id 27 if data[:data].any? && data[:data].first.user.id != @twitter_id
28 wrong_user = data[:data].first.user 28 wrong_user = data[:data].first.user
29 Rails.logger.warn "Wrong timeline data. Requested: #{@twitter_id}, got: #{wrong_user.id} (#{wrong_user.name.printable})" 29 throw "Wrong timeline data. Requested: #{@twitter_id}, got: #{wrong_user.id} (#{wrong_user.name.printable})"
30 end 30 end
31 31
32 data[:data] = data[:data].select do |tweet| 32 data[:data] = data[:data].select do |tweet|
33 tweet.retweeted_status.nil? || tweet.user.id != tweet.retweeted_status.user.id 33 tweet.retweeted_status.nil? || tweet.user.id != tweet.retweeted_status.user.id
34 end.map { |tweet| tweet.to_h } 34 end.map { |tweet| tweet.to_h }