2017-11-18 10:16:48 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-15 01:53:31 +11:00
|
|
|
class Api::V1::Timelines::ListController < Api::V1::Timelines::BaseController
|
2018-07-06 02:31:35 +10:00
|
|
|
before_action -> { doorkeeper_authorize! :read, :'read:lists' }
|
2017-11-18 10:16:48 +11:00
|
|
|
before_action :require_user!
|
|
|
|
before_action :set_list
|
|
|
|
before_action :set_statuses
|
|
|
|
|
2023-11-15 01:53:31 +11:00
|
|
|
PERMITTED_PARAMS = %i(limit).freeze
|
2017-11-18 10:16:48 +11:00
|
|
|
|
|
|
|
def show
|
|
|
|
render json: @statuses,
|
|
|
|
each_serializer: REST::StatusSerializer,
|
|
|
|
relationships: StatusRelationshipsPresenter.new(@statuses, current_user.account_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_list
|
|
|
|
@list = List.where(account: current_account).find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_statuses
|
2024-05-16 18:03:46 +10:00
|
|
|
@statuses = preloaded_list_statuses
|
2017-11-18 10:16:48 +11:00
|
|
|
end
|
|
|
|
|
2024-05-16 18:03:46 +10:00
|
|
|
def preloaded_list_statuses
|
|
|
|
preload_collection list_statuses, Status
|
2017-11-18 10:16:48 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def list_statuses
|
|
|
|
list_feed.get(
|
|
|
|
limit_param(DEFAULT_STATUSES_LIMIT),
|
|
|
|
params[:max_id],
|
2018-09-28 10:23:45 +10:00
|
|
|
params[:since_id],
|
|
|
|
params[:min_id]
|
2017-11-18 10:16:48 +11:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def list_feed
|
|
|
|
ListFeed.new(@list)
|
|
|
|
end
|
|
|
|
|
|
|
|
def next_path
|
2023-11-15 01:53:31 +11:00
|
|
|
api_v1_timelines_list_url params[:id], next_path_params
|
2017-11-18 10:16:48 +11:00
|
|
|
end
|
|
|
|
|
|
|
|
def prev_path
|
2023-11-15 01:53:31 +11:00
|
|
|
api_v1_timelines_list_url params[:id], prev_path_params
|
2017-11-18 10:16:48 +11:00
|
|
|
end
|
|
|
|
end
|