Mercurial > rsstweet
annotate app/controllers/tweets_controller.rb @ 234:7a773720d81f legit-client
Totally legit client
author | nanaya <me@nanaya.net> |
---|---|
date | Fri, 14 Jul 2023 22:42:20 +0900 |
parents | 0f0cc55ff11b |
children | 4222343d9433 |
rev | line source |
---|---|
15 | 1 class TweetsController < ApplicationController |
38
9e03bbbb1d43
Move static#index to tweet#index.
edogawaconan <me@myconan.net>
parents:
28
diff
changeset
|
2 def index |
234 | 3 return redirect if params[:name].present? |
38
9e03bbbb1d43
Move static#index to tweet#index.
edogawaconan <me@myconan.net>
parents:
28
diff
changeset
|
4 end |
9e03bbbb1d43
Move static#index to tweet#index.
edogawaconan <me@myconan.net>
parents:
28
diff
changeset
|
5 |
15 | 6 def show |
233 | 7 return redirect if params[:id][/\D/].present? |
165 | 8 |
234 | 9 @user = CachedFetch.user_by_id params[:id] |
10 | |
11 if @user.nil? | |
12 head :not_found | |
13 return | |
14 end | |
165 | 15 |
203
af84c9f23263
Fix redirect for twitter user with nil screen name
nanaya <me@nanaya.pro>
parents:
166
diff
changeset
|
16 return redirect if normalized_screen_name != params[:name] |
165 | 17 |
234 | 18 @tweets = CachedFetch.timeline params[:id] |
19 | |
20 head :not_found if @tweets.nil? | |
15 | 21 end |
55
8f68ca606099
Add twitter id to the url so it'll be consistent.
nanaya <me@myconan.net>
parents:
48
diff
changeset
|
22 |
165 | 23 def redirect |
234 | 24 @user ||= CachedFetch.user_by_username(params[:name]) |
25 | |
26 if @user.nil? | |
27 head :not_found | |
28 else | |
29 redirect_to tweet_path(@user[:id], normalized_screen_name) | |
30 end | |
55
8f68ca606099
Add twitter id to the url so it'll be consistent.
nanaya <me@myconan.net>
parents:
48
diff
changeset
|
31 end |
203
af84c9f23263
Fix redirect for twitter user with nil screen name
nanaya <me@nanaya.pro>
parents:
166
diff
changeset
|
32 |
af84c9f23263
Fix redirect for twitter user with nil screen name
nanaya <me@nanaya.pro>
parents:
166
diff
changeset
|
33 private |
205 | 34 |
203
af84c9f23263
Fix redirect for twitter user with nil screen name
nanaya <me@nanaya.pro>
parents:
166
diff
changeset
|
35 def normalized_screen_name |
234 | 36 @user[:username].presence || '_' |
203
af84c9f23263
Fix redirect for twitter user with nil screen name
nanaya <me@nanaya.pro>
parents:
166
diff
changeset
|
37 end |
15 | 38 end |