A platform for community discussion. Free, open, simple.
FIX: let user recover their own deleted topics (#35214)
Régis Hanol391fff46d38e
diff --git a/app/assets/javascripts/discourse/app/models/post.js b/app/assets/javascripts/discourse/app/models/post.jsindex a50e90ba448..a60d936810a 100644--- a/app/assets/javascripts/discourse/app/models/post.js+++ b/app/assets/javascripts/discourse/app/models/post.js@@ -362,11 +362,20 @@ export default class Post extends RestModel {}get canRecoverTopic() {- return this.firstPost && this.deleted && this.topic.details.can_recover;+ return (+ this.firstPost &&+ (this.deleted || this.user_deleted) &&+ this.topic.details.can_recover+ );}get isRecoveringTopic() {- return this.firstPost && !this.deleted && this.topic.details.can_recover;+ return (+ this.firstPost &&+ !this.deleted &&+ !this.user_deleted &&+ this.topic.details.can_recover+ );}get canRecover() {diff --git a/spec/system/post_menu_spec.rb b/spec/system/post_menu_spec.rbindex c08242566da..d510a827b24 100644--- a/spec/system/post_menu_spec.rb+++ b/spec/system/post_menu_spec.rb@@ -305,6 +305,20 @@ describe "Post menu", type: :system dotopic_page.click_post_action_button(post2, :recover)expect(topic_page).to have_no_deleted_post(post2)end++ it "allows regular users to recover their own deleted topic" do+ user_topic = Fabricate(:topic, user: user)+ user_first_post = Fabricate(:post, topic: user_topic, user: user, post_number: 1)+ PostDestroyer.new(user, user_first_post).destroy++ sign_in(user)++ topic_page.visit_topic(user_topic)++ expect(topic_page).to have_post_action_button(user_first_post, :recover)+ topic_page.click_post_action_button(user_first_post, :recover)+ expect(topic_page).to have_no_deleted_post(user_first_post)+ endenddescribe "edit" do