Collections API: Set a maximum for the pagination limit param (#39342)

This commit is contained in:
David Roetzel 2026-06-09 12:31:58 +02:00 committed by GitHub
parent fef5a501cc
commit 4fcb28e081
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,6 +4,7 @@ class Api::V1::CollectionsController < Api::BaseController
include Authorization
DEFAULT_COLLECTIONS_LIMIT = 40
MAX_COLLECTIONS_LIMIT = 100
rescue_from ActiveRecord::RecordInvalid, Mastodon::ValidationError do |e|
render json: { error: ValidationErrorFormatter.new(e).as_json }, status: 422
@ -73,7 +74,7 @@ class Api::V1::CollectionsController < Api::BaseController
.with_tag
.order(created_at: :desc)
.offset(offset_param)
.limit(limit_param(DEFAULT_COLLECTIONS_LIMIT))
.limit(limit_param(DEFAULT_COLLECTIONS_LIMIT, MAX_COLLECTIONS_LIMIT))
@collections = @collections.discoverable unless @account == current_account
end