diff app/helpers/application_helper.rb @ 234:7a773720d81f legit-client

Totally legit client
author nanaya <me@nanaya.net>
date Fri, 14 Jul 2023 22:42:20 +0900
parents 12287b32fbda
children 3ac13a9e593d
line wrap: on
line diff
--- a/app/helpers/application_helper.rb	Fri Jul 14 01:45:40 2023 +0900
+++ b/app/helpers/application_helper.rb	Fri Jul 14 22:42:20 2023 +0900
@@ -5,27 +5,17 @@
     "tag:rsstweet@nanaya.pro,2014:#{id}"
   end
 
-  def expand_url(text, *urls)
-    urls.flatten!
-
-    urls = urls.reduce({}) do |result, u|
-      if u.try(:[], :url)
-        result[u[:url]] = u[:expanded_url]
-      end
-
-      result
-    end
-
+  def expand_url(text, urls)
     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