Fix: リモートからの参照を無限に受け入れる問題

This commit is contained in:
KMY 2024-02-02 09:05:53 +09:00
parent 9a5f80c41d
commit 7333390e88
4 changed files with 153 additions and 8 deletions

View file

@ -5,8 +5,6 @@ class ActivityPub::ReferencesController < ActivityPub::BaseController
include Authorization
include AccountOwnedConcern
REFERENCES_LIMIT = 5
before_action :require_signature!, if: :authorized_fetch_mode?
before_action :set_status
@ -40,17 +38,21 @@ class ActivityPub::ReferencesController < ActivityPub::BaseController
@results ||= begin
references = @status.reference_objects.order(target_status_id: :asc)
references = references.where('target_status_id > ?', page_params[:min_id]) if page_params[:min_id].present?
references = references.limit(limit_param(REFERENCES_LIMIT))
references = references.limit(limit_param(references_limit))
references.pluck(:target_status_id)
end
end
def references_limit
StatusReference::REFERENCES_LIMIT
end
def pagination_min_id
results.last
end
def records_continue?
results.size == limit_param(REFERENCES_LIMIT)
results.size == limit_param(references_limit)
end
def references_collection_presenter