diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-03-01 02:47:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-01 02:47:59 +0100 |
commit | fce8464077dfca64c3bc9a52b7bcde50c9ac555e (patch) | |
tree | e99eedf4a8e23ae1415ac51e833751510e6ec2b4 /app/controllers/api/v1/accounts | |
parent | 47bdb9b33b021c92bdfc6698914776eda13f6f77 (diff) |
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.
Diffstat (limited to 'app/controllers/api/v1/accounts')
-rw-r--r-- | app/controllers/api/v1/accounts/search_controller.rb | 4 | ||||
-rw-r--r-- | app/controllers/api/v1/accounts/statuses_controller.rb | 6 |
2 files changed, 3 insertions, 7 deletions
diff --git a/app/controllers/api/v1/accounts/search_controller.rb b/app/controllers/api/v1/accounts/search_controller.rb index 11e647c3c..7649da433 100644 --- a/app/controllers/api/v1/accounts/search_controller.rb +++ b/app/controllers/api/v1/accounts/search_controller.rb @@ -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 diff --git a/app/controllers/api/v1/accounts/statuses_controller.rb b/app/controllers/api/v1/accounts/statuses_controller.rb index 095f6937b..7261ccd24 100644 --- a/app/controllers/api/v1/accounts/statuses_controller.rb +++ b/app/controllers/api/v1/accounts/statuses_controller.rb @@ -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 |