changeset 100:c1d5d8be92c6

Add support for extended tweets
author nanaya <me@myconan.net>
date Fri, 23 Sep 2016 23:02:16 +0900
parents 56fd4829e599
children e7a665227638
files app/models/tweet.rb app/views/tweets/_tweet.html.erb
diffstat 2 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/app/models/tweet.rb	Sat Sep 17 13:42:12 2016 +0900
+++ b/app/models/tweet.rb	Fri Sep 23 23:02:16 2016 +0900
@@ -9,7 +9,7 @@
     begin
       @timeline ||=
         Rails.cache.fetch({ :timeline => @twitter_id }, :expires_in => cache_expires_time) do
-          @client.user_timeline(@twitter_id, :count => 40, :exclude_replies => false, :include_rts => true)
+          @client.user_timeline(@twitter_id, :count => 40, :exclude_replies => false, :include_rts => true, :tweet_mode => :extended)
         end
     rescue Twitter::Error::TooManyRequests
       next_client_config_id = @client_config_id + 1
--- a/app/views/tweets/_tweet.html.erb	Sat Sep 17 13:42:12 2016 +0900
+++ b/app/views/tweets/_tweet.html.erb	Fri Sep 23 23:02:16 2016 +0900
@@ -6,7 +6,8 @@
   <%= render "tweet", :tweet => tweet.retweeted_status %>
 <% else%>
   <p>
-    <%= auto_link(expand_url(tweet.text)).gsub("\n", "<br>").html_safe %>
+    <%# FIXME: Twitter gem doesn't support extended mode when writing this %>
+    <%= auto_link(expand_url(tweet.to_hash[:full_text])).gsub("\n", "<br>").html_safe %>
   </p>
 
   <p>