Collections API: Set a maximum for the pagination limit param (#39342)
This commit is contained in:
parent
fef5a501cc
commit
4fcb28e081
@ -4,6 +4,7 @@ class Api::V1::CollectionsController < Api::BaseController
|
|||||||
include Authorization
|
include Authorization
|
||||||
|
|
||||||
DEFAULT_COLLECTIONS_LIMIT = 40
|
DEFAULT_COLLECTIONS_LIMIT = 40
|
||||||
|
MAX_COLLECTIONS_LIMIT = 100
|
||||||
|
|
||||||
rescue_from ActiveRecord::RecordInvalid, Mastodon::ValidationError do |e|
|
rescue_from ActiveRecord::RecordInvalid, Mastodon::ValidationError do |e|
|
||||||
render json: { error: ValidationErrorFormatter.new(e).as_json }, status: 422
|
render json: { error: ValidationErrorFormatter.new(e).as_json }, status: 422
|
||||||
@ -73,7 +74,7 @@ class Api::V1::CollectionsController < Api::BaseController
|
|||||||
.with_tag
|
.with_tag
|
||||||
.order(created_at: :desc)
|
.order(created_at: :desc)
|
||||||
.offset(offset_param)
|
.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
|
@collections = @collections.discoverable unless @account == current_account
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user