mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: validate topic deletion when acting on a flag
This commit is contained in:
@@ -87,7 +87,7 @@ class Admin::FlagsController < Admin::AdminController
|
||||
|
||||
if delete_post
|
||||
# PostDestroy calls PostAction.agree_flags!
|
||||
PostDestroyer.new(current_user, post).destroy
|
||||
destroy_post(post)
|
||||
elsif restore_post
|
||||
PostAction.agree_flags!(post, current_user, delete_post)
|
||||
PostDestroyer.new(current_user, post).recover
|
||||
@@ -131,9 +131,19 @@ class Admin::FlagsController < Admin::AdminController
|
||||
)
|
||||
|
||||
PostAction.defer_flags!(post, current_user, params[:delete_post])
|
||||
PostDestroyer.new(current_user, post).destroy if params[:delete_post]
|
||||
destroy_post(post) if params[:delete_post]
|
||||
|
||||
render body: nil
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def destroy_post(post)
|
||||
if post.is_first_post?
|
||||
topic = Topic.find_by(id: post.topic_id)
|
||||
guardian.ensure_can_delete!(topic) if topic.present?
|
||||
end
|
||||
|
||||
PostDestroyer.new(current_user, post).destroy
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user