FIX: Ensure soft-deleted topics can be deleted (#19802)

* FIX: Ensure soft-deleted topics can be deleted

The topic was not found during the deletion process because it was
deleted and `@post.topic` was nil.

* DEV: Use @topic instead of finding the topic every time
This commit is contained in:
Bianca Nenciu
2023-01-27 16:15:33 +02:00
committed by GitHub
parent bffb15e13b
commit 8fc11215e1
5 changed files with 59 additions and 35 deletions

View File

@@ -649,7 +649,9 @@ class TopicsController < ApplicationController
force_destroy = ActiveModel::Type::Boolean.new.cast(params[:force_destroy])
if force_destroy
if !guardian.can_permanently_delete?(topic)
if !topic
raise Discourse::InvalidAccess
elsif !guardian.can_permanently_delete?(topic)
return render_json_error topic.cannot_permanently_delete_reason(current_user), status: 403
end
else