Ensure that boolean params in the API are parsed for truthiness (#6575)
Use Rails smart boolean cast to account for values such as "f", "0", "false", etc. Previously, if a param was present in the request, it would count as true.
This commit is contained in:
parent
47bdb9b33b
commit
fce8464077
7 changed files with 13 additions and 17 deletions
|
@ -22,8 +22,4 @@ class Api::V1::Accounts::SearchController < Api::BaseController
|
|||
following: truthy_param?(:following)
|
||||
)
|
||||
end
|
||||
|
||||
def truthy_param?(key)
|
||||
params[key] == 'true'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,9 +28,9 @@ class Api::V1::Accounts::StatusesController < Api::BaseController
|
|||
|
||||
def account_statuses
|
||||
default_statuses.tap do |statuses|
|
||||
statuses.merge!(only_media_scope) if params[:only_media]
|
||||
statuses.merge!(pinned_scope) if params[:pinned]
|
||||
statuses.merge!(no_replies_scope) if params[:exclude_replies]
|
||||
statuses.merge!(only_media_scope) if truthy_param?(:only_media)
|
||||
statuses.merge!(pinned_scope) if truthy_param?(:pinned)
|
||||
statuses.merge!(no_replies_scope) if truthy_param?(:exclude_replies)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue