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