From 11852056a849a32fb957c1bf6a58a6180819973e Mon Sep 17 00:00:00 2001 From: Antonin Hildebrand Date: Fri, 15 May 2015 15:24:48 +0800 Subject: [PATCH] Add missing events for discourse-hipchat-plugin https://github.com/binaryage/discourse-hipchat-plugin --- app/controllers/topics_controller.rb | 4 ++++ lib/post_destroyer.rb | 2 ++ 2 files changed, 6 insertions(+) diff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rb index 523813c108e..683768dfc25 100644 --- a/app/controllers/topics_controller.rb +++ b/app/controllers/topics_controller.rb @@ -261,6 +261,8 @@ class TopicsController < ApplicationController first_post = topic.ordered_posts.first PostDestroyer.new(current_user, first_post, { context: params[:context] }).destroy + DiscourseEvent.trigger(:topic_destroyed, topic, current_user) + render nothing: true end @@ -271,6 +273,8 @@ class TopicsController < ApplicationController first_post = topic.posts.with_deleted.order(:post_number).first PostDestroyer.new(current_user, first_post).recover + DiscourseEvent.trigger(:topic_recovered, topic, current_user) + render nothing: true end diff --git a/lib/post_destroyer.rb b/lib/post_destroyer.rb index 7a093629d0c..fb6bd9079c9 100644 --- a/lib/post_destroyer.rb +++ b/lib/post_destroyer.rb @@ -46,6 +46,7 @@ class PostDestroyer elsif @user.id == @post.user_id mark_for_deletion end + DiscourseEvent.trigger(:post_destroyed, @post, @opts, @user) end def recover @@ -57,6 +58,7 @@ class PostDestroyer topic = Topic.with_deleted.find @post.topic_id topic.recover! if @post.is_first_post? topic.update_statistics + DiscourseEvent.trigger(:post_recovered, @post, @opts, @user) end def staff_recovered