about summary refs log tree commit diff
path: root/app/controllers/api/v1/timelines_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/api/v1/timelines_controller.rb')
-rw-r--r--app/controllers/api/v1/timelines_controller.rb26
1 files changed, 12 insertions, 14 deletions
diff --git a/app/controllers/api/v1/timelines_controller.rb b/app/controllers/api/v1/timelines_controller.rb
index 0446b9e4d..e55e7d718 100644
--- a/app/controllers/api/v1/timelines_controller.rb
+++ b/app/controllers/api/v1/timelines_controller.rb
@@ -1,8 +1,8 @@
 # frozen_string_literal: true
 
 class Api::V1::TimelinesController < ApiController
-  before_action -> { doorkeeper_authorize! :read }
-  before_action :require_user!, only: [:home, :mentions]
+  before_action -> { doorkeeper_authorize! :read }, only: [:home]
+  before_action :require_user!, only: [:home]
 
   respond_to :json
 
@@ -11,11 +11,9 @@ class Api::V1::TimelinesController < ApiController
     @statuses = cache_collection(@statuses)
 
     set_maps(@statuses)
-    # set_counters_maps(@statuses)
-    # set_account_counters_maps(@statuses.flat_map { |s| [s.account, s.reblog? ? s.reblog.account : nil] }.compact.uniq)
 
-    next_path = api_v1_home_timeline_url(max_id: @statuses.last.id)    unless @statuses.empty?
-    prev_path = api_v1_home_timeline_url(since_id: @statuses.first.id) unless @statuses.empty?
+    next_path = api_v1_home_timeline_url(pagination_params(max_id: @statuses.last.id))    unless @statuses.empty?
+    prev_path = api_v1_home_timeline_url(pagination_params(since_id: @statuses.first.id)) unless @statuses.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -27,11 +25,9 @@ class Api::V1::TimelinesController < ApiController
     @statuses = cache_collection(@statuses)
 
     set_maps(@statuses)
-    # set_counters_maps(@statuses)
-    # set_account_counters_maps(@statuses.flat_map { |s| [s.account, s.reblog? ? s.reblog.account : nil] }.compact.uniq)
 
-    next_path = api_v1_public_timeline_url(max_id: @statuses.last.id)    unless @statuses.empty?
-    prev_path = api_v1_public_timeline_url(since_id: @statuses.first.id) unless @statuses.empty?
+    next_path = api_v1_public_timeline_url(pagination_params(max_id: @statuses.last.id))    unless @statuses.empty?
+    prev_path = api_v1_public_timeline_url(pagination_params(since_id: @statuses.first.id)) unless @statuses.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -44,11 +40,9 @@ class Api::V1::TimelinesController < ApiController
     @statuses = cache_collection(@statuses)
 
     set_maps(@statuses)
-    # set_counters_maps(@statuses)
-    # set_account_counters_maps(@statuses.flat_map { |s| [s.account, s.reblog? ? s.reblog.account : nil] }.compact.uniq)
 
-    next_path = api_v1_hashtag_timeline_url(params[:id], max_id: @statuses.last.id)    unless @statuses.empty?
-    prev_path = api_v1_hashtag_timeline_url(params[:id], since_id: @statuses.first.id) unless @statuses.empty?
+    next_path = api_v1_hashtag_timeline_url(params[:id], pagination_params(max_id: @statuses.last.id))    unless @statuses.empty?
+    prev_path = api_v1_hashtag_timeline_url(params[:id], pagination_params(since_id: @statuses.first.id)) unless @statuses.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -60,4 +54,8 @@ class Api::V1::TimelinesController < ApiController
   def cache_collection(raw)
     super(raw, Status)
   end
+
+  def pagination_params(core_params)
+    params.permit(:local, :limit).merge(core_params)
+  end
 end