mirror of
https://github.com/discourse/discourse.git
synced 2026-08-26 13:17:20 -05:00
Delegate bulk operations to a TopicsBulkAction object.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
require_dependency 'topic_view'
|
||||
require_dependency 'promotion'
|
||||
require_dependency 'url_helper'
|
||||
require_dependency 'topics_bulk_action'
|
||||
|
||||
class TopicsController < ApplicationController
|
||||
include UrlHelper
|
||||
@@ -269,7 +270,11 @@ class TopicsController < ApplicationController
|
||||
|
||||
def bulk
|
||||
topic_ids = params.require(:topic_ids).map {|t| t.to_i}
|
||||
render_json_dump topic_ids: topic_ids
|
||||
operation = params.require(:operation).symbolize_keys
|
||||
raise ActionController::ParameterMissing.new(:operation_type) if operation[:type].blank?
|
||||
operator = TopicsBulkAction.new(current_user, topic_ids, operation)
|
||||
changed_topic_ids = operator.perform!
|
||||
render_json_dump topic_ids: changed_topic_ids
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user