1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
This commit is contained in:
Matt Jankowski 2024-07-31 14:07:11 +00:00 committed by GitHub
commit 0e9fc17013
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 43 additions and 25 deletions

View file

@ -26,7 +26,7 @@ class Api::V1::Admin::AccountActionsController < Api::BaseController
end end
def resource_params def resource_params
params.permit( params_slice(
:type, :type,
:report_id, :report_id,
:warning_preset_id, :warning_preset_id,

View file

@ -108,7 +108,7 @@ class Api::V1::Admin::AccountsController < Api::BaseController
end end
def filter_params def filter_params
params.permit(*FILTER_PARAMS) params_slice(*FILTER_PARAMS)
end end
def translated_filter_params def translated_filter_params

View file

@ -67,7 +67,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
end end
def domain_block_params def domain_block_params
params.permit(:severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate) params_slice(:severity, :reject_media, :reject_reports, :private_comment, :public_comment, :obfuscate)
end end
def next_path def next_path

View file

@ -56,7 +56,7 @@ class Api::V1::Admin::IpBlocksController < Api::BaseController
end end
def resource_params def resource_params
params.permit(:ip, :severity, :comment, :expires_in) params_slice(:ip, :severity, :comment, :expires_in)
end end
def next_path def next_path

View file

@ -82,11 +82,13 @@ class Api::V1::Admin::ReportsController < Api::BaseController
end end
def report_params def report_params
params.permit(:category, rule_ids: []) params
.slice(:category, :rule_ids)
.permit(:category, rule_ids: [])
end end
def filter_params def filter_params
params.permit(*FILTER_PARAMS) params_slice(*FILTER_PARAMS)
end end
def next_path def next_path

View file

@ -20,10 +20,12 @@ class Api::V1::AppsController < Api::BaseController
end end
def app_scopes_or_default def app_scopes_or_default
app_params[:scopes] || Doorkeeper.configuration.default_scopes Array(app_params[:scopes]).first || Doorkeeper.configuration.default_scopes
end end
def app_params def app_params
params.permit(:client_name, :scopes, :website, :redirect_uris, redirect_uris: []) params
.slice(:client_name, :scopes, :website, :redirect_uris, :redirect_uris)
.permit(:client_name, :scopes, :website, :redirect_uris, redirect_uris: [], scopes: [])
end end
end end

View file

@ -52,7 +52,9 @@ class Api::V1::FiltersController < Api::BaseController
end end
def resource_params def resource_params
params.permit(:phrase, :expires_in, :irreversible, :whole_word, context: []) params
.slice(:phrase, :expires_in, :irreversible, :whole_word, :context)
.permit(:phrase, :expires_in, :irreversible, :whole_word, context: [])
end end
def filter_params def filter_params

View file

@ -52,7 +52,7 @@ class Api::V1::Lists::AccountsController < Api::BaseController
end end
def resource_params def resource_params
params.permit(account_ids: []) params.slice(:account_ids).permit(account_ids: [])
end end
def next_path def next_path

View file

@ -42,6 +42,6 @@ class Api::V1::ListsController < Api::BaseController
end end
def list_params def list_params
params.permit(:title, :replies_policy, :exclusive) params_slice(:title, :replies_policy, :exclusive)
end end
end end

View file

@ -40,11 +40,11 @@ class Api::V1::MediaController < Api::BaseController
end end
def media_attachment_params def media_attachment_params
params.permit(:file, :thumbnail, :description, :focus) params_slice(:file, :thumbnail, :description, :focus)
end end
def updateable_media_attachment_params def updateable_media_attachment_params
params.permit(:thumbnail, :description, :focus) params_slice(:thumbnail, :description, :focus)
end end
def file_type_error def file_type_error

View file

@ -85,7 +85,9 @@ class Api::V1::NotificationsController < Api::BaseController
end end
def browserable_params def browserable_params
params.permit(:account_id, :include_filtered, types: [], exclude_types: []) params
.slice(:account_id, :include_filtered, :types, :exclude_types)
.permit(:account_id, :include_filtered, types: [], exclude_types: [])
end end
def pagination_params(core_params) def pagination_params(core_params)

View file

@ -23,6 +23,8 @@ class Api::V1::ReportsController < Api::BaseController
end end
def report_params def report_params
params.permit(:account_id, :comment, :category, :forward, forward_to_domains: [], status_ids: [], rule_ids: []) params
.slice(:account_id, :comment, :category, :forward, :forward_to_domains, :status_ids, :rule_ids)
.permit(:account_id, :comment, :category, :forward, :rule_ids, forward_to_domains: [], status_ids: [], rule_ids: [])
end end
end end

View file

@ -50,6 +50,6 @@ class Api::V1::Statuses::ReblogsController < Api::V1::Statuses::BaseController
end end
def reblog_params def reblog_params
params.permit(:visibility) params_slice(:visibility)
end end
end end

View file

@ -12,6 +12,7 @@ class Api::V2::Admin::AccountsController < Api::V1::Admin::AccountsController
ip ip
invited_by invited_by
role_ids role_ids
role_ids: []
).freeze ).freeze
PAGINATION_PARAMS = (%i(limit) + FILTER_PARAMS).freeze PAGINATION_PARAMS = (%i(limit) + FILTER_PARAMS).freeze
@ -39,7 +40,7 @@ class Api::V2::Admin::AccountsController < Api::V1::Admin::AccountsController
end end
def filter_params def filter_params
params.permit(*FILTER_PARAMS, role_ids: []) params_slice(*FILTER_PARAMS)
end end
def pagination_params(core_params) def pagination_params(core_params)

View file

@ -45,6 +45,6 @@ class Api::V2::Filters::KeywordsController < Api::BaseController
end end
def resource_params def resource_params
params.permit(:keyword, :whole_word) params_slice(:keyword, :whole_word)
end end
end end

View file

@ -39,6 +39,6 @@ class Api::V2::Filters::StatusesController < Api::BaseController
end end
def resource_params def resource_params
params.permit(:status_id) params_slice(:status_id)
end end
end end

View file

@ -43,6 +43,8 @@ class Api::V2::FiltersController < Api::BaseController
end end
def resource_params def resource_params
params.permit(:title, :expires_in, :filter_action, context: [], keywords_attributes: [:id, :keyword, :whole_word, :_destroy]) params
.slice(:title, :expires_in, :filter_action, :context, :keywords_attributes)
.permit(:title, :expires_in, :filter_action, context: [], keywords_attributes: [:id, :keyword, :whole_word, :_destroy])
end end
end end

View file

@ -63,6 +63,6 @@ class Api::V2::SearchController < Api::BaseController
end end
def search_params def search_params
params.permit(:type, :offset, :min_id, :max_id, :account_id, :following) params.permit(:q, :resolve, :type, :offset, :min_id, :max_id, :account_id, :following)
end end
end end

View file

@ -125,10 +125,15 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
end end
def browserable_params def browserable_params
params.permit(:include_filtered, types: [], exclude_types: []) params
.slice(:include_filtered, :types, :exclude_types)
.permit(:include_filtered, types: [], exclude_types: [])
end end
def pagination_params(core_params) def pagination_params(core_params)
params.slice(:limit, :types, :exclude_types, :include_filtered).permit(:limit, :include_filtered, types: [], exclude_types: []).merge(core_params) params
.slice(:limit, :types, :exclude_types, :include_filtered)
.permit(:limit, :include_filtered, types: [], exclude_types: [])
.merge(core_params)
end end
end end

View file

@ -15,7 +15,7 @@ module Admin::FilterHelper
AnnouncementFilter::KEYS, AnnouncementFilter::KEYS,
Admin::ActionLogFilter::KEYS, Admin::ActionLogFilter::KEYS,
Admin::StatusFilter::KEYS, Admin::StatusFilter::KEYS,
].flatten.freeze ].flatten.uniq.freeze
def filter_link_to(text, link_to_params, link_class_params = link_to_params) def filter_link_to(text, link_to_params, link_class_params = link_to_params)
new_url = filtered_url_for(link_to_params) new_url = filtered_url_for(link_to_params)
@ -48,6 +48,6 @@ module Admin::FilterHelper
end end
def controller_request_params def controller_request_params
params.permit(FILTERS) params.slice(FILTERS).permit(FILTERS)
end end
end end