comparison app/controllers/tweets_controller.rb @ 207:f9fd9d9cab97

Handle banned account
author nanaya <me@nanaya.pro>
date Mon, 19 Oct 2020 14:22:45 +0900
parents 8190fa511e35
children 0f0cc55ff11b
comparison
equal deleted inserted replaced
206:a3c140f01707 207:f9fd9d9cab97
10 @user = client.user 10 @user = client.user
11 11
12 return redirect if normalized_screen_name != params[:name] 12 return redirect if normalized_screen_name != params[:name]
13 13
14 @tweets = client.timeline 14 @tweets = client.timeline
15 rescue Twitter::Error::Forbidden
16 head :forbidden
15 rescue Twitter::Error::NotFound 17 rescue Twitter::Error::NotFound
16 head :not_found 18 head :not_found
17 rescue Twitter::Error::Unauthorized 19 rescue Twitter::Error::Unauthorized
18 head :forbidden 20 head :forbidden
19 end 21 end
20 22
21 def redirect 23 def redirect
22 @user ||= Tweet.new(params[:id].presence || params[:name]).user 24 @user ||= Tweet.new(params[:id].presence || params[:name]).user
23 redirect_to tweet_path(@user.id, normalized_screen_name) 25 redirect_to tweet_path(@user.id, normalized_screen_name)
26 rescue Twitter::Error::Forbidden
27 head :forbidden
24 rescue Twitter::Error::NotFound 28 rescue Twitter::Error::NotFound
25 head :not_found 29 head :not_found
26 rescue Twitter::Error::Unauthorized 30 rescue Twitter::Error::Unauthorized
27 head :forbidden 31 head :forbidden
28 end 32 end