]> cat aescling's git repositories - mastodon.git/blob - app/controllers/api/v1/timelines_controller.rb
Move timelines API from statuses to its own controller, add a check for
[mastodon.git] / app / controllers / api / v1 / timelines_controller.rb
1 class Api::V1::TimelinesController < ApiController
2 before_action -> { doorkeeper_authorize! :read }
3 before_action :require_user!, only: [:home, :mentions]
4
5 respond_to :json
6
7 def home
8 @statuses = Feed.new(:home, current_account).get(20, params[:max_id], params[:since_id]).to_a
9 set_maps(@statuses)
10 render action: :index
11 end
12
13 def mentions
14 @statuses = Feed.new(:mentions, current_account).get(20, params[:max_id], params[:since_id]).to_a
15 set_maps(@statuses)
16 render action: :index
17 end
18
19 def public
20 @statuses = Status.as_public_timeline(current_account).paginate_by_max_id(20, params[:max_id], params[:since_id]).to_a
21 set_maps(@statuses)
22 render action: :index
23 end
24
25 def tag
26 @tag = Tag.find_by(name: params[:id].downcase)
27
28 if @tag.nil?
29 @statuses = []
30 else
31 @statuses = Status.as_tag_timeline(@tag, current_account).paginate_by_max_id(20, params[:max_id], params[:since_id]).to_a
32 set_maps(@statuses)
33 end
34
35 render action: :index
36 end
37 end
This page took 0.073856 seconds and 4 git commands to generate.