From a54aaeeb79fb8875e499d71d8c95dcec88f87fb4 Mon Sep 17 00:00:00 2001 From: Mark VanLandingham Date: Wed, 4 Dec 2019 14:13:31 -0600 Subject: [PATCH] REFACTOR: post_destroyer destroy method (#8462) --- lib/post_destroyer.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index 2b74d83791f..4e09ed8f883 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -56,8 +56,9 @@ class PostDestroyer def destroy payload = WebHook.generate_payload(:post, @post) if WebHook.active_web_hooks(:post).exists? topic = @post.topic + is_first_post = @post.is_first_post? && topic - if @post.is_first_post? && topic + if is_first_post topic_view = TopicView.new(topic.id, Discourse.system_user) topic_payload = WebHook.generate_payload(:topic, topic_view, WebHookTopicViewSerializer) if WebHook.active_web_hooks(:topic).exists? end @@ -75,10 +76,10 @@ class PostDestroyer DiscourseEvent.trigger(:post_destroyed, @post, @opts, @user) WebHook.enqueue_post_hooks(:post_destroyed, @post, payload) - if @post.is_first_post? && @post.topic - UserActionManager.topic_destroyed(@post.topic) - DiscourseEvent.trigger(:topic_destroyed, @post.topic, @user) - WebHook.enqueue_topic_hooks(:topic_destroyed, @post.topic, topic_payload) + if is_first_post + UserActionManager.topic_destroyed(topic) + DiscourseEvent.trigger(:topic_destroyed, topic, @user) + WebHook.enqueue_topic_hooks(:topic_destroyed, topic, topic_payload) end end