FEATURE: Create revision when bulk moving topics (#10802)

This behavior can be configured with the new "create_revision_on_bulk_topic_moves" site setting. It's enabled by default.
This commit is contained in:
Gerhard Schlager
2020-11-12 13:57:12 +01:00
committed by GitHub
parent a4441b3984
commit 6ff07bb73f
4 changed files with 76 additions and 9 deletions

View File

@ -86,9 +86,26 @@ class TopicsBulkAction
end
def change_category
topics.each do |t|
if guardian.can_edit?(t)
@changed_ids << t.id if t.change_category_to_id(@operation[:category_id])
updatable_topics = topics.where.not(category_id: @operation[:category_id])
if SiteSetting.create_revision_on_bulk_topic_moves
opts = {
bypass_bump: true,
validate_post: false,
bypass_rate_limiter: true
}
updatable_topics.each do |t|
if guardian.can_edit?(t)
changes = { category_id: @operation[:category_id] }
@changed_ids << t.id if t.first_post.revise(@user, changes, opts)
end
end
else
updatable_topics.each do |t|
if guardian.can_edit?(t)
@changed_ids << t.id if t.change_category_to_id(@operation[:category_id])
end
end
end
end