A platform for community discussion. Free, open, simple.
FIX: Don't error out after destroying first post with webhook configured (#31902)
Ted Johansson1cde30e6bd7a
diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rbindex 0e715b2409d..c4dbf06900f 100644--- a/lib/post_destroyer.rb+++ b/lib/post_destroyer.rb@@ -85,7 +85,7 @@ class PostDestroyerUserActionManager.topic_destroyed(@topic)DiscourseEvent.trigger(:topic_destroyed, @topic, @user)if WebHook.active_web_hooks(:topic_destroyed).exists?- topic_view = TopicView.new(@topic.id, Discourse.system_user, skip_staff_action: true)+ topic_view = TopicView.new(@topic, Discourse.system_user, skip_staff_action: true)topic_payload = WebHook.generate_payload(:topic, topic_view, WebHookTopicViewSerializer)WebHook.enqueue_topic_hooks(:topic_destroyed, @topic, topic_payload)enddiff --git a/spec/lib/post_destroyer_spec.rb b/spec/lib/post_destroyer_spec.rbindex 8cb10a50497..fb0afd854a3 100644--- a/spec/lib/post_destroyer_spec.rb+++ b/spec/lib/post_destroyer_spec.rb@@ -1142,6 +1142,8 @@ RSpec.describe PostDestroyer doendit "destroys the post when force_destroy is true for soft deleted topics" do+ Fabricate(:topic_web_hook)+post = Fabricate(:post)topic = post.topic