2017-11-18 08:16:48 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-14 23:53:31 +09:00
|
|
|
class Api::V1::Timelines::ListController < Api::V1::Timelines::BaseController
|
2018-07-06 01:31:35 +09:00
|
|
|
before_action -> { doorkeeper_authorize! :read, :'read:lists' }
|
2017-11-18 08:16:48 +09:00
|
|
|
before_action :require_user!
|
|
|
|
before_action :set_list
|
|
|
|
before_action :set_statuses
|
|
|
|
|
2023-11-14 23:53:31 +09:00
|
|
|
PERMITTED_PARAMS = %i(limit).freeze
|
2017-11-18 08:16:48 +09: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 17:03:46 +09:00
|
|
|
@statuses = preloaded_list_statuses
|
2017-11-18 08:16:48 +09:00
|
|
|
end
|
|
|
|
|
2024-05-16 17:03:46 +09:00
|
|
|
def preloaded_list_statuses
|
|
|
|
preload_collection list_statuses, Status
|
2017-11-18 08:16:48 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
def list_statuses
|
|
|
|
list_feed.get(
|
|
|
|
limit_param(DEFAULT_STATUSES_LIMIT),
|
|
|
|
params[:max_id],
|
2018-09-28 09:23:45 +09:00
|
|
|
params[:since_id],
|
|
|
|
params[:min_id]
|
2017-11-18 08:16:48 +09:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def list_feed
|
|
|
|
ListFeed.new(@list)
|
|
|
|
end
|
|
|
|
|
|
|
|
def next_path
|
2023-11-14 23:53:31 +09:00
|
|
|
api_v1_timelines_list_url params[:id], next_path_params
|
2017-11-18 08:16:48 +09:00
|
|
|
end
|
|
|
|
|
|
|
|
def prev_path
|
2023-11-14 23:53:31 +09:00
|
|
|
api_v1_timelines_list_url params[:id], prev_path_params
|
2017-11-18 08:16:48 +09:00
|
|
|
end
|
|
|
|
end
|