From ddab7cc239c0e186351279b2e1f22c4552c0e553 Mon Sep 17 00:00:00 2001 From: Ahmed Gagan Date: Thu, 10 Sep 2020 21:48:45 +0530 Subject: [PATCH] DEV: Add plugin api to permit bulk_action parameters (#10638) --- app/controllers/topics_controller.rb | 2 +- lib/discourse_plugin_registry.rb | 2 ++ lib/plugin/instance.rb | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 3db2290855f..d6fadb3ba37 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -868,7 +868,7 @@ class TopicsController < ApplicationController operation = params .require(:operation) - .permit(:type, :group, :category_id, :notification_level_id, tags: []) + .permit(:type, :group, :category_id, :notification_level_id, *DiscoursePluginRegistry.permitted_bulk_action_parameters, tags: []) .to_h.symbolize_keys raise ActionController::ParameterMissing.new(:operation_type) if operation[:type].blank? diff --git a/lib/discourse_plugin_registry.rb b/lib/discourse_plugin_registry.rb index 93e2c117f30..9e87e1374d9 100644 --- a/lib/discourse_plugin_registry.rb +++ b/lib/discourse_plugin_registry.rb @@ -82,6 +82,8 @@ class DiscoursePluginRegistry define_filtered_register :api_parameter_routes define_filtered_register :api_key_scope_mappings + define_filtered_register :permitted_bulk_action_parameters + def self.register_auth_provider(auth_provider) self.auth_providers << auth_provider end diff --git a/lib/plugin/instance.rb b/lib/plugin/instance.rb index e0dec5ff24e..4729223a9e5 100644 --- a/lib/plugin/instance.rb +++ b/lib/plugin/instance.rb @@ -899,4 +899,8 @@ class Plugin::Instance end nil end + + def register_permitted_bulk_action_parameter(name) + DiscoursePluginRegistry.register_permitted_bulk_action_parameter(name, self) + end end