changeset 207:f9fd9d9cab97

Handle banned account
author nanaya <me@nanaya.pro>
date Mon, 19 Oct 2020 14:22:45 +0900
parents a3c140f01707
children ef836405c9eb
files app/controllers/tweets_controller.rb
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/tweets_controller.rb	Mon Oct 19 04:10:15 2020 +0900
+++ b/app/controllers/tweets_controller.rb	Mon Oct 19 14:22:45 2020 +0900
@@ -12,6 +12,8 @@
     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
@@ -21,6 +23,8 @@
   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