mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 09:51:24 +00:00
Extract limit methods
This commit is contained in:
parent
e8d91b1b24
commit
914f6b411a
|
@ -20,16 +20,6 @@ class Api::V1::Statuses::ContextsController < Api::BaseController
|
|||
def show
|
||||
cache_if_unauthenticated!
|
||||
|
||||
ancestors_limit = CONTEXT_LIMIT
|
||||
descendants_limit = CONTEXT_LIMIT
|
||||
descendants_depth_limit = nil
|
||||
|
||||
if current_account.nil?
|
||||
ancestors_limit = ANCESTORS_LIMIT
|
||||
descendants_limit = DESCENDANTS_LIMIT
|
||||
descendants_depth_limit = DESCENDANTS_DEPTH_LIMIT
|
||||
end
|
||||
|
||||
ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(ancestors_limit, current_account)
|
||||
descendants_results = @status.descendants(descendants_limit, current_account, descendants_depth_limit)
|
||||
loaded_ancestors = preload_collection(ancestors_results, Status)
|
||||
|
@ -57,6 +47,18 @@ class Api::V1::Statuses::ContextsController < Api::BaseController
|
|||
|
||||
private
|
||||
|
||||
def ancestors_limit
|
||||
current_account.present? ? CONTEXT_LIMIT : ANCESTORS_LIMIT
|
||||
end
|
||||
|
||||
def descendants_limit
|
||||
current_account.present? ? CONTEXT_LIMIT : DESCENDANTS_LIMIT
|
||||
end
|
||||
|
||||
def descendants_depth_limit
|
||||
current_account.present? ? nil : DESCENDANTS_DEPTH_LIMIT
|
||||
end
|
||||
|
||||
def set_status
|
||||
@status = Status.find(params[:status_id])
|
||||
authorize @status, :show?
|
||||
|
|
Loading…
Reference in New Issue
Block a user