REFACTOR: post_destroyer destroy method (#8462)

This commit is contained in:
Mark VanLandingham 2019-12-04 14:13:31 -06:00 committed by GitHub
parent b13f427450
commit a54aaeeb79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -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