# HG changeset patch # User nanaya # Date 1689535389 -32400 # Node ID 2935c5e52a713e256bf026d18323a95e76c7c555 # Parent 0f0cc55ff11bda4383a999c18161a6b1c6bd0aa5# Parent ebb65a26f070752e25b61f4b0d01e9f4bcc9b412 No more official twitter api diff -r 0f0cc55ff11b -r 2935c5e52a71 Gemfile --- a/Gemfile Fri Jul 14 01:45:40 2023 +0900 +++ b/Gemfile Mon Jul 17 04:23:09 2023 +0900 @@ -8,7 +8,6 @@ gem "redis" -gem "twitter" gem "twitter-text" gem "newrelic_rpm" diff -r 0f0cc55ff11b -r 2935c5e52a71 Gemfile.lock --- a/Gemfile.lock Fri Jul 14 01:45:40 2023 +0900 +++ b/Gemfile.lock Mon Jul 17 04:23:09 2023 +0900 @@ -19,46 +19,20 @@ i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) - buftok (0.2.0) builder (3.2.4) concurrent-ruby (1.1.10) connection_pool (2.3.0) crass (1.0.6) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) - equalizer (0.0.11) erubi (1.12.0) - ffi (1.15.5) - ffi-compiler (1.0.1) - ffi (>= 1.0.0) - rake - http (4.4.1) - addressable (~> 2.3) - http-cookie (~> 1.0) - http-form_data (~> 2.2) - http-parser (~> 1.2.0) - http-cookie (1.0.5) - domain_name (~> 0.5) - http-form_data (2.3.0) - http-parser (1.2.3) - ffi-compiler (>= 1.0, < 2.0) - http_parser.rb (0.6.0) - http_parser.rb (0.6.0-java) i18n (1.12.0) concurrent-ruby (~> 1.0) idn-ruby (0.1.5) loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) - memoizable (0.4.2) - thread_safe (~> 0.3, >= 0.3.1) method_source (1.0.0) mini_portile2 (2.8.1) minitest (5.17.0) - multipart-post (2.2.3) - naught (1.1.0) newrelic_rpm (8.15.0) nio4r (2.5.8) nio4r (2.5.8-java) @@ -69,7 +43,6 @@ racc (~> 1.4) nokogiri (1.14.0-x86-mingw32) racc (~> 1.4) - public_suffix (5.0.1) puma (6.0.2) nio4r (~> 2.0) puma (6.0.2-java) @@ -96,21 +69,7 @@ redis-client (>= 0.9.0) redis-client (0.12.0) connection_pool - simple_oauth (0.3.1) thor (1.2.1) - thread_safe (0.3.6) - thread_safe (0.3.6-java) - twitter (7.0.0) - addressable (~> 2.3) - buftok (~> 0.2.0) - equalizer (~> 0.0.11) - http (~> 4.0) - http-form_data (~> 2.0) - http_parser.rb (~> 0.6.0) - memoizable (~> 0.4.0) - multipart-post (~> 2.0) - naught (~> 1.0) - simple_oauth (~> 0.3.0) twitter-text (3.1.0) idn-ruby unf (~> 0.1.0) @@ -134,7 +93,6 @@ puma railties (~> 7.0.1) redis - twitter twitter-text BUNDLED WITH diff -r 0f0cc55ff11b -r 2935c5e52a71 app/controllers/tweets_controller.rb --- a/app/controllers/tweets_controller.rb Fri Jul 14 01:45:40 2023 +0900 +++ b/app/controllers/tweets_controller.rb Mon Jul 17 04:23:09 2023 +0900 @@ -1,39 +1,43 @@ class TweetsController < ApplicationController def index - return redirect if params[:id].present? || params[:name].present? + return redirect if params[:name].present? end def show return redirect if params[:id][/\D/].present? - client = Tweet.new(params[:id].to_i) - @user = client.user + @user = CachedFetch.user_by_id params[:id] + + if @user.nil? + head :not_found + return + end + + if @user[:protected] + head :forbidden + return + end return redirect if normalized_screen_name != params[:name] - @tweets = client.timeline - rescue Twitter::Error::Forbidden - head :forbidden - rescue Twitter::Error::NotFound - head :not_found - rescue Twitter::Error::Unauthorized - head :forbidden + @tweets = CachedFetch.timeline params[:id] + + head :not_found if @tweets.nil? end def redirect - @user ||= Tweet.new(params[:id].presence || params[:name]).user - redirect_to tweet_path(@user.id, normalized_screen_name) - rescue Twitter::Error::Forbidden - head :forbidden - rescue Twitter::Error::NotFound - head :not_found - rescue Twitter::Error::Unauthorized - head :forbidden + @user ||= CachedFetch.user_by_username(params[:name]) + + if @user.nil? + head :not_found + else + redirect_to tweet_path(@user[:id], normalized_screen_name) + end end private def normalized_screen_name - @user.screen_name.presence || '_' + @user[:username].presence || '_' end end diff -r 0f0cc55ff11b -r 2935c5e52a71 app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb Fri Jul 14 01:45:40 2023 +0900 +++ b/app/helpers/application_helper.rb Mon Jul 17 04:23:09 2023 +0900 @@ -5,27 +5,23 @@ "tag:rsstweet@nanaya.pro,2014:#{id}" end - def expand_url(text, *urls) - urls.flatten! + def expand_url(text, urls) + text.gsub /https?:\/\/t\.co\/[A-Za-z0-9]+/ do |url| + expanded = urls[url] - urls = urls.reduce({}) do |result, u| - if u.try(:[], :url) - result[u[:url]] = u[:expanded_url] + case expanded + when nil then url + when Hash then expanded[:url] + else expanded end - - result - end - - text.gsub /https?:\/\/t\.co\/[A-Za-z0-9]+/ do |url| - urls[url] || url end end def status_url(tweet) - status_url_base tweet.user.screen_name, tweet.id + status_url_base tweet[:user][:username], tweet[:id] end - def status_url_base(screen_name, tweet_id) - "https://twitter.com/#{screen_name.presence || '_'}/status/#{tweet_id}" + def status_url_base(username, id) + "https://twitter.com/#{username.presence || '_'}/status/#{id}" end end diff -r 0f0cc55ff11b -r 2935c5e52a71 app/lib/cached_fetch.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/lib/cached_fetch.rb Mon Jul 17 04:23:09 2023 +0900 @@ -0,0 +1,17 @@ +module CachedFetch + def self.timeline(user_id) + cached("timeline:#{user_id}") { LegitClient.timeline(user_id)&.[](:timeline) } + end + + def self.user_by_id(user_id) + cached("user_by_id:#{user_id}") { LegitClient.user_by_id(user_id)&.[](:user) } + end + + def self.user_by_username(username) + cached("user_by_username:#{username}") { LegitClient.user_by_username(username)&.[](:user) } + end + + def self.cached(key, &block) + Rails.cache.fetch(key, expires_in: (15 + rand(60)).minutes, &block) + end +end diff -r 0f0cc55ff11b -r 2935c5e52a71 app/lib/clients.rb --- a/app/lib/clients.rb Fri Jul 14 01:45:40 2023 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,23 +0,0 @@ -class Clients - def self.client_options(id) - { - :timeouts => { - :connect => 5, - :read => 5, - :write => 5, - }, - }.merge $cfg[:twitter][id] - end - - def self.instance - @@instance ||= self.new - end - - def initialize - @clients = {} - end - - def get(id) - @clients[id] ||= Twitter::REST::Client.new(self.class.client_options id) - end -end diff -r 0f0cc55ff11b -r 2935c5e52a71 app/lib/legit_client.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/lib/legit_client.rb Mon Jul 17 04:23:09 2023 +0900 @@ -0,0 +1,152 @@ +module LegitClient + def self.timeline(user_id) + resp = fetch("https://twitter.com/i/api/graphql/1-5o8Qhfc2kWlu_2rWNcug/UserTweetsAndReplies?variables=%7B%22userId%22%3A#{escape_param user_id}%2C%22count%22%3A50%2C%22includePromotedContent%22%3Atrue%2C%22withCommunity%22%3Atrue%2C%22withVoice%22%3Atrue%2C%22withV2Timeline%22%3Atrue%7D&features=%7B%22rweb_lists_timeline_redesign_enabled%22%3Atrue%2C%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22tweetypie_unmention_optimization_enabled%22%3Atrue%2C%22responsive_web_edit_tweet_api_enabled%22%3Atrue%2C%22graphql_is_translatable_rweb_tweet_is_translatable_enabled%22%3Atrue%2C%22view_counts_everywhere_api_enabled%22%3Atrue%2C%22longform_notetweets_consumption_enabled%22%3Atrue%2C%22responsive_web_twitter_article_tweet_consumption_enabled%22%3Afalse%2C%22tweet_awards_web_tipping_enabled%22%3Afalse%2C%22freedom_of_speech_not_reach_fetch_enabled%22%3Atrue%2C%22standardized_nudges_misinfo%22%3Atrue%2C%22tweet_with_visibility_results_prefer_gql_limited_actions_policy_enabled%22%3Atrue%2C%22longform_notetweets_rich_text_read_enabled%22%3Atrue%2C%22longform_notetweets_inline_media_enabled%22%3Atrue%2C%22responsive_web_media_download_video_enabled%22%3Afalse%2C%22responsive_web_enhance_cards_enabled%22%3Afalse%7D&fieldToggles=%7B%22withAuxiliaryUserLabels%22%3Afalse%2C%22withArticleRichContentState%22%3Afalse%7D") + + handle_response resp, :timeline, "timeline(#{user_id})", ->(json) do + normalize_timeline json['data']['user']['result']['timeline_v2']['timeline']['instructions'], user_id + end + end + + def self.user_by_id(user_id) + resp = fetch("https://twitter.com/i/api/graphql/i_0UQ54YrCyqLUvgGzXygA/UserByRestId?variables=%7B%22userId%22%3A#{escape_param user_id}%2C%22withSafetyModeUserFields%22%3Atrue%7D&features=%7B%22hidden_profile_likes_enabled%22%3Afalse%2C%22hidden_profile_subscriptions_enabled%22%3Afalse%2C%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22highlights_tweets_tab_ui_enabled%22%3Atrue%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%7D&fieldToggles=%7B%22withAuxiliaryUserLabels%22%3Afalse%7D") + + handle_response resp, :user, "user_by_id(#{user_id})", ->(json) do + normalize_user json['data']['user']['result'] + end + end + + def self.user_by_username(username) + resp = fetch("https://twitter.com/i/api/graphql/xc8f1g7BYqr6VTzTbvNlGw/UserByScreenName?variables=%7B%22screen_name%22%3A#{escape_param username}%2C%22withSafetyModeUserFields%22%3Atrue%7D&features=%7B%22hidden_profile_likes_enabled%22%3Afalse%2C%22hidden_profile_subscriptions_enabled%22%3Afalse%2C%22responsive_web_graphql_exclude_directive_enabled%22%3Atrue%2C%22verified_phone_label_enabled%22%3Afalse%2C%22subscriptions_verification_info_verified_since_enabled%22%3Atrue%2C%22highlights_tweets_tab_ui_enabled%22%3Atrue%2C%22creator_subscriptions_tweet_preview_api_enabled%22%3Atrue%2C%22responsive_web_graphql_skip_user_profile_image_extensions_enabled%22%3Afalse%2C%22responsive_web_graphql_timeline_navigation_enabled%22%3Atrue%7D&fieldToggles=%7B%22withAuxiliaryUserLabels%22%3Afalse%7D") + + handle_response resp, :user, "user_by_username(#{username})", ->(json) do + normalize_user json['data']['user']['result'] + end + end + + def self.escape_param(param) + CGI.escape JSON.dump(param) + end + + def self.fetch(uri) + Net::HTTP.get(URI(uri), $cfg[:headers].sample) + end + + def self.handle_response(resp, key, error_key, callback) + json = JSON.parse(resp) + { + key => callback.call(json), + raw: resp, + } + rescue => e + if json.is_a? Hash + if json['errors'].is_a? Array + return rate_limit_check(json) + elsif json['data'].is_a? Hash + return + end + end + Rails.logger.error("#{error_key} fail: #{resp}") + + raise e + end + + def self.normalize_entity_media(json) + ret = {} + + json.each do |entity_media| + val = {} + + if entity_media['type'] == 'photo' + val[:image_url] = entity_media['media_url_https'] + elsif entity_media['type'] == 'video' + val[:variants] = entity_media['video_info']['variants'] + .filter { |variant| variant['bitrate'].present? } + .map do |variant| + { + bitrate: variant['bitrate'], + url: variant['url'], + } + end + end + + if !val.empty? + val[:url] = entity_media['expanded_url'] + val[:type] = entity_media['type'] + val[:id] = entity_media['media_key'] + end + + key = if ret[entity_media['url']].nil? + entity_media['url'] + else + entity_media['media_key'] + end + + ret[key] = val + end + + ret + end + + def self.normalize_entity_urls(json) + ret = {} + + (json || {}).each do |entity_url| + ret[entity_url['url']] = entity_url['expanded_url'] + end + + ret + end + + def self.normalize_timeline(json, user_id) + json.find { |instruction| instruction['type'] == 'TimelineAddEntries' }['entries'] + .filter { |entry| entry['entryId'] =~ /\A(profile-conversation|tweet)-/ } + .reduce([]) do |acc, entry| + if entry['content']['entryType'] == 'TimelineTimelineItem' + acc.push(entry['content']) + else + entry['content']['items'].each do |item| + acc.push(item['item']) + end + end + acc + end.map { |rawTweet| normalize_tweet(rawTweet['itemContent']['tweet_results']['result']) } + .filter { |tweet| !tweet.nil? && tweet.dig(:user, :id) == user_id } + end + + def self.normalize_tweet(json) + return nil if json.nil? + + return normalize_tweet(json['tweet']) if json['__typename'] == 'TweetWithVisibilityResults' + + { + id: json['rest_id'], + created_at: Time.parse(json['legacy']['created_at']), + user: normalize_user(json['core']['user_results']['result']), + message: json.dig('note_tweet', 'note_tweet_results', 'result', 'text') || json['legacy']['full_text'], + retweet: normalize_tweet(json.dig('legacy', 'retweeted_status_result', 'result')), + quote: normalize_tweet(json.dig('quoted_status_result', 'result')), + quote_id: json['legacy']['quoted_status_id_str'], + reply_to_id: json['legacy']['in_reply_to_status_id_str'], + reply_to_user_id: json['legacy']['in_reply_to_user_id_str'], + reply_to_username: json['legacy']['in_reply_to_screen_name'], + entity_urls: { **normalize_entity_urls(json['legacy']['entities']['urls']), **normalize_entity_urls(json.dig('note_tweet', 'note_tweet_results', 'result', 'entity_set', 'urls')) }, + entity_media: normalize_entity_media(json.dig('legacy', 'extended_entities', 'media') || []), + } + end + + def self.normalize_user(json) + { + avatar_url: json['legacy']['profile_image_url_https'], + id: json['rest_id'], + name: json['legacy']['name'], + protected: json['legacy']['protected'] == true, + username: json['legacy']['screen_name'], + } + end + + def self.rate_limit_check(json) + return unless json['errors'].any? { |err| err['code'] == 88 } + + raise 'Rate limited!' + end +end diff -r 0f0cc55ff11b -r 2935c5e52a71 app/models/tweet.rb --- a/app/models/tweet.rb Fri Jul 14 01:45:40 2023 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -class Tweet - TIMELINE_OPTIONS = { - :count => 100, - :exclude_replies => false, - :include_rts => true, - :tweet_mode => :extended, - } - - def self.cache_expires_time - (15 + rand(15)).minutes - end - - def initialize(twitter_id) - @twitter_id = twitter_id - end - - def id - user.id - end - - def timeline - if @timeline.nil? - cache_key = "timeline:v2:#{id}/#{Base64.urlsafe_encode64 id.to_s}" - raw = Rails.cache.fetch(cache_key, :expires_in => self.class.cache_expires_time) do - client_try(:user_timeline, id, TIMELINE_OPTIONS).tap do |data| - if data[:result] == :ok - if data[:data].any? && data[:data].first.user.id != id - wrong_user = data[:data].first.user - throw "Wrong timeline data. Requested: #{id}, got: #{wrong_user.id} (#{wrong_user.screen_name.printable})" - end - - data[:data] = data[:data].select do |tweet| - tweet.retweeted_status.nil? || tweet.user.id != tweet.retweeted_status.user.id - end.map { |tweet| tweet.to_h } - end - end - end - - raise Twitter::Error::NotFound if raw[:result] == :not_found - - @timeline = raw[:data].map { |tweet_hash| Twitter::Tweet.new(tweet_hash) } - end - - @timeline - end - - def user - if @user.nil? - cache_key = "user:v1:#{@twitter_id.is_a?(Integer) ? 'id' : 'lookup'}:#{@twitter_id}" - raw = Rails.cache.fetch(cache_key, :expires_in => self.class.cache_expires_time) do - client_try(:user, @twitter_id).tap do |data| - if data[:result] == :ok - user = data[:data] - - if user.id != @twitter_id && user.screen_name.downcase != @twitter_id.try(:downcase) - throw "Wrong user data. Requested: #{@twitter_id}, got: #{user.id} (#{user.screen_name.printable})" - end - end - end - end - - raise Twitter::Error::NotFound if raw[:result] == :not_found - - @user = raw[:data] - end - - @user - end - - def client - Clients.instance.get client_config_id - end - - def client_try(method, *args) - initial_config_id = client_config_id - - begin - data = client.public_send method, *args - rescue Twitter::Error::TooManyRequests - @client_config_id = (1 + @client_config_id) % @client_config_count - - if initial_config_id == client_config_id - raise - else - retry - end - rescue Twitter::Error::NotFound - return { :result => :not_found } - end - - { :result => :ok, :data => data } - end - - def client_config_id - @client_config_count ||= $cfg[:twitter].size - @client_config_id ||= rand(@client_config_count) - - @client_config_id - end -end diff -r 0f0cc55ff11b -r 2935c5e52a71 app/views/tweets/_tweet.atom.erb --- a/app/views/tweets/_tweet.atom.erb Fri Jul 14 01:45:40 2023 +0900 +++ b/app/views/tweets/_tweet.atom.erb Mon Jul 17 04:23:09 2023 +0900 @@ -1,13 +1,16 @@ - <%= atom_id "#{tweet.user.id}/#{tweet.id}" %> - <%= tweet.created_at.xmlschema %> - <%= tweet.created_at.xmlschema %> + <% + created_at = tweet[:created_at].xmlschema + %> + <%= atom_id "#{tweet[:user][:id]}/#{tweet[:id]}" %> + <%= created_at %> + <%= created_at %> - <%= truncate tweet.unescaped_text, :length => 30 %> + <%= truncate tweet[:message], :length => 30 %> <%= render(:partial => "tweet", :formats => :html, :locals => { :tweet => tweet }).to_str %> - <%= tweet.user.screen_name %> + <%= tweet[:user][:username] %> diff -r 0f0cc55ff11b -r 2935c5e52a71 app/views/tweets/_tweet.html.erb --- a/app/views/tweets/_tweet.html.erb Fri Jul 14 01:45:40 2023 +0900 +++ b/app/views/tweets/_tweet.html.erb Mon Jul 17 04:23:09 2023 +0900 @@ -1,34 +1,32 @@ -<% if tweet.retweeted_status.present? %> +<% if tweet[:retweet].present? %>

- <%= link_to status_url(tweet.retweeted_status) do %> + <%= link_to status_url(tweet[:retweet]) do %> Retweeted: <% end %>

- <%= render "tweet", :tweet => tweet.retweeted_status, :with_time => true %> -<% else%> + <%= render "tweet", :tweet => tweet[:retweet], :with_time => true %> +<% else %> <% if defined?(with_time) && with_time %>

- Originally tweeted at <%= tweet.created_at.rfc822 %> + Originally tweeted at <%= tweet[:created_at].rfc822 %>

<% end %> - <% if tweet.in_reply_to_status_id.present? %> + <% if tweet[:reply_to_id].present? %>

Replying to - <%= link_to 'tweet', status_url_base(tweet.in_reply_to_screen_name, tweet.in_reply_to_status_id) %> - by <%= link_to tweet.in_reply_to_screen_name, "https://twitter.com/#{tweet.in_reply_to_screen_name}" %> + <%= link_to 'tweet', status_url_base(tweet[:reply_to_username], tweet[:reply_to_id]) %> + by <%= link_to "@#{tweet[:reply_to_username]}", "https://twitter.com/#{tweet[:reply_to_username]}" %>

<% end %>

- <%# FIXME: Twitter gem doesn't support extended mode when writing this %> <%= auto_link(expand_url( - tweet.full_text_extended, - tweet.attrs[:entities][:urls], - tweet.attrs[:entities][:media] + tweet[:message], + { **tweet[:entity_urls], **tweet[:entity_media] } )) .gsub("\n", "
") .html_safe @@ -36,31 +34,36 @@

- <%= link_to "https://twitter.com/#{tweet.user.screen_name}" do %> - <%= image_tag tweet.user.profile_image_url_https.to_s, :alt => "profile image for #{tweet.user.name.printable}" %> - <%= tweet.user.name.printable -%> + <%= link_to "https://twitter.com/#{tweet[:user][:username]}" do %> + <%= image_tag tweet[:user][:avatar_url].to_s, :alt => "profile image for #{tweet[:user][:name].printable}" %> + <%= tweet[:user][:name].printable -%> <% end %>

- <% tweet.media.each_with_index do |media, i| %> - <% if media.is_a? Twitter::Media::Photo %> - <%= link_to "#{media.media_url_https}?name=orig" do %> - <%= image_tag "#{media.media_url_https}?name=small", :alt => "attachment #{i + 1}" -%> + <% tweet[:entity_media].each do |_short_url, media| %> + <% if media[:type] == 'photo' %> + <%= link_to "#{media[:image_url]}?name=orig" do %> + <%= image_tag "#{media[:image_url]}?name=small", :alt => "attachment #{media[:id]}" -%> <% end %> - <% elsif media.is_a? Twitter::Media::Video %> - <%= video_tag media.video_info.variants - .select { |i| i.bitrate.is_a? Integer } - .sort_by { |i| -i.bitrate } - .map(&:url), width: '100%', controls: true + <% elsif media[:type] == 'video' %> + <%= video_tag media[:variants] + .sort_by { |variant| -variant[:bitrate] } + .map { |variant| variant[:url] }, width: '100%', controls: true %> <% end %> <% end %>

- <% if tweet.quoted_status.present? %> + <% if tweet[:quote_id].present? %>
- <%= render "tweet", :tweet => tweet.quoted_status, :with_time => true %> + <% if tweet[:quote].present? %> + <%= render "tweet", :tweet => tweet[:quote], :with_time => true %> + <% else %> + <%= link_to status_url_base(nil, tweet[:quote_id]) do %> + Preview not available, view tweet directly. + <% end %> + <% end %>
<% end %> <% end %> diff -r 0f0cc55ff11b -r 2935c5e52a71 app/views/tweets/show.atom.erb --- a/app/views/tweets/show.atom.erb Fri Jul 14 01:45:40 2023 +0900 +++ b/app/views/tweets/show.atom.erb Mon Jul 17 04:23:09 2023 +0900 @@ -1,15 +1,15 @@ - <%= atom_id(@user.id) %> + <%= atom_id(@user[:id]) %> - + - <%= "#{@user.name.printable} (#{@user.screen_name})" %> - <%= @user.profile_image_url_https %> - <%= @user.profile_image_url_https %> + <%= "#{@user[:name].printable} (#{@user[:username]})" %> + <%= @user[:avatar_url] %> + <%= @user[:avatar_url] %> - <%= (@tweets.first.try(:created_at) || Time.at(0)).xmlschema %> + <%= (@tweets.first.try(:[], :created_at) || Time.at(0)).xmlschema %> <%= render :partial => "tweet", :collection => @tweets, :cached => true %> diff -r 0f0cc55ff11b -r 2935c5e52a71 config/initializers/ext_twitter_tweet.rb --- a/config/initializers/ext_twitter_tweet.rb Fri Jul 14 01:45:40 2023 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ -class Twitter::Tweet - def full_text_extended - attrs[:full_text].printable - end - memoize :full_text_extended - - def unescaped_text - CGI.unescapeHTML full_text_extended - end - memoize :unescaped_text -end diff -r 0f0cc55ff11b -r 2935c5e52a71 config/initializers/twitter_tweet_cache_key.rb --- a/config/initializers/twitter_tweet_cache_key.rb Fri Jul 14 01:45:40 2023 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -class Twitter::Tweet - def cache_key - "twitter/tweet/#{id}" - end -end