2023-11-14 06:53:31 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Api::V1::Timelines::BaseController < Api::BaseController
|
|
|
|
after_action :insert_pagination_headers, unless: -> { @statuses.empty? }
|
|
|
|
|
2024-07-04 07:26:49 -07:00
|
|
|
before_action :require_user!, if: :require_auth?
|
|
|
|
|
2023-11-14 06:53:31 -08:00
|
|
|
private
|
|
|
|
|
2024-07-04 07:26:49 -07:00
|
|
|
def require_auth?
|
|
|
|
!Setting.timeline_preview
|
|
|
|
end
|
|
|
|
|
2024-03-13 01:51:44 -07:00
|
|
|
def pagination_collection
|
|
|
|
@statuses
|
2023-11-14 06:53:31 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
def next_path_params
|
|
|
|
permitted_params.merge(max_id: pagination_max_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def prev_path_params
|
|
|
|
permitted_params.merge(min_id: pagination_since_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def permitted_params
|
|
|
|
params
|
|
|
|
.slice(*self.class::PERMITTED_PARAMS)
|
|
|
|
.permit(*self.class::PERMITTED_PARAMS)
|
|
|
|
end
|
|
|
|
end
|