1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00

Compare commits

...

22 commits

Author SHA1 Message Date
Matt Jankowski
6f13c94e6f
Merge 9aa8e29758 into 549ab089ee 2024-07-31 11:06:49 +00:00
Matt Jankowski
9aa8e29758 Use params_slice in api/v1/statuses/reblogs controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
f9f558da7f Use params.slice in api/v2_alpha/notifications controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
50bcdf5371 Use params.slice in api/v1/admin/reports controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
8a705c479e Use params_slice in api/v1/media controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
e133d908f1 Use params_slice in api/v1/admin/reports controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
ade3a65676 Use params.slice in api/v1/apps controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
6b43a08902 Use params.slice in api/v1/reports controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
6486f58ef4 Use params.slice in api/v1/filters controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
8a5595eb8d Use params.slice in api/v2/filters controller 2024-07-18 13:28:36 -04:00
Matt Jankowski
519ec1c9da Use params.slice in api/v1/notifications controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
058a3d8467 Use params.slice in api/v1/lists/accounts controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
41708456a1 Use params_slice in api/v2/admin/accounts controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
7066147622 Use params_slice in api/v1/admin/accounts controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
169e524f46 Use params slice and uniq constant in admin::filter_helper 2024-07-18 13:28:35 -04:00
Matt Jankowski
e29478ae69 Use params_slice in api/v1/admin/ip_blocks controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
d9f7780598 Use params_slice in api/v1/lists controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
a8ccfd227b Use params_slice in api/v1/admin/domain_blocks controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
3f4c231186 Use params_slice in api/v2/filters/statuses controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
db9f834f47 Use params_slice in api/v2/filters/keywords controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
7e04f35373 Use params_slice in api/v1/admin/accounts controller 2024-07-18 13:28:35 -04:00
Matt Jankowski
c66942aa0a Add missing params to api/v2/search controller 2024-07-18 13:28:35 -04:00
20 changed files with 43 additions and 25 deletions

View file

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

View file

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

View file

@ -67,7 +67,7 @@ class Api::V1::Admin::DomainBlocksController < Api::BaseController
end
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
def next_path

View file

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

View file

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

View file

@ -20,10 +20,12 @@ class Api::V1::AppsController < Api::BaseController
end
def app_scopes_or_default
app_params[:scopes] || Doorkeeper.configuration.default_scopes
Array(app_params[:scopes]).first || Doorkeeper.configuration.default_scopes
end
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

View file

@ -52,7 +52,9 @@ class Api::V1::FiltersController < Api::BaseController
end
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
def filter_params

View file

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

View file

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

View file

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

View file

@ -85,7 +85,9 @@ class Api::V1::NotificationsController < Api::BaseController
end
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
def pagination_params(core_params)

View file

@ -23,6 +23,8 @@ class Api::V1::ReportsController < Api::BaseController
end
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

View file

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

View file

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

View file

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

View file

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

View file

@ -43,6 +43,8 @@ class Api::V2::FiltersController < Api::BaseController
end
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

View file

@ -63,6 +63,6 @@ class Api::V2::SearchController < Api::BaseController
end
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

View file

@ -125,10 +125,15 @@ class Api::V2Alpha::NotificationsController < Api::BaseController
end
def browserable_params
params.permit(:include_filtered, types: [], exclude_types: [])
params
.slice(:include_filtered, :types, :exclude_types)
.permit(:include_filtered, types: [], exclude_types: [])
end
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

View file

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