Change logged out /api/v1/statuses/:id/context logged out limits (#20355)

main
Claire 2 years ago committed by GitHub
parent 894ce3726a
commit 1615c3eb6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,14 +18,29 @@ class Api::V1::StatusesController < Api::BaseController
# than this anyway # than this anyway
CONTEXT_LIMIT = 4_096 CONTEXT_LIMIT = 4_096
# This remains expensive and we don't want to show everything to logged-out users
ANCESTORS_LIMIT = 40
DESCENDANTS_LIMIT = 60
DESCENDANTS_DEPTH_LIMIT = 20
def show def show
@status = cache_collection([@status], Status).first @status = cache_collection([@status], Status).first
render json: @status, serializer: REST::StatusSerializer render json: @status, serializer: REST::StatusSerializer
end end
def context def context
ancestors_results = @status.in_reply_to_id.nil? ? [] : @status.ancestors(CONTEXT_LIMIT, current_account) ancestors_limit = CONTEXT_LIMIT
descendants_results = @status.descendants(CONTEXT_LIMIT, current_account) 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, nil, nil, descendants_depth_limit)
loaded_ancestors = cache_collection(ancestors_results, Status) loaded_ancestors = cache_collection(ancestors_results, Status)
loaded_descendants = cache_collection(descendants_results, Status) loaded_descendants = cache_collection(descendants_results, Status)

Loading…
Cancel
Save