REFACTOR: post_destroyer destroy method (#8462)
This commit is contained in:
parent
b13f427450
commit
a54aaeeb79
|
@ -56,8 +56,9 @@ class PostDestroyer
|
||||||
def destroy
|
def destroy
|
||||||
payload = WebHook.generate_payload(:post, @post) if WebHook.active_web_hooks(:post).exists?
|
payload = WebHook.generate_payload(:post, @post) if WebHook.active_web_hooks(:post).exists?
|
||||||
topic = @post.topic
|
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_view = TopicView.new(topic.id, Discourse.system_user)
|
||||||
topic_payload = WebHook.generate_payload(:topic, topic_view, WebHookTopicViewSerializer) if WebHook.active_web_hooks(:topic).exists?
|
topic_payload = WebHook.generate_payload(:topic, topic_view, WebHookTopicViewSerializer) if WebHook.active_web_hooks(:topic).exists?
|
||||||
end
|
end
|
||||||
|
@ -75,10 +76,10 @@ class PostDestroyer
|
||||||
DiscourseEvent.trigger(:post_destroyed, @post, @opts, @user)
|
DiscourseEvent.trigger(:post_destroyed, @post, @opts, @user)
|
||||||
WebHook.enqueue_post_hooks(:post_destroyed, @post, payload)
|
WebHook.enqueue_post_hooks(:post_destroyed, @post, payload)
|
||||||
|
|
||||||
if @post.is_first_post? && @post.topic
|
if is_first_post
|
||||||
UserActionManager.topic_destroyed(@post.topic)
|
UserActionManager.topic_destroyed(topic)
|
||||||
DiscourseEvent.trigger(:topic_destroyed, @post.topic, @user)
|
DiscourseEvent.trigger(:topic_destroyed, topic, @user)
|
||||||
WebHook.enqueue_topic_hooks(:topic_destroyed, @post.topic, topic_payload)
|
WebHook.enqueue_topic_hooks(:topic_destroyed, topic, topic_payload)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue