From 626965f94cba5671ff1078eab1917a2775e69831 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 27 Sep 2017 14:04:27 -0400 Subject: [PATCH] FIX: Use a proper event for removing assign on close --- lib/topic_assigner.rb | 6 ------ plugin.rb | 7 +++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/topic_assigner.rb b/lib/topic_assigner.rb index 886895e..94e6489 100644 --- a/lib/topic_assigner.rb +++ b/lib/topic_assigner.rb @@ -44,12 +44,6 @@ SQL end def self.auto_assign(post, force: false) - - if SiteSetting.unassign_on_close && post.topic && post.topic.closed - assigner = new(post.topic, Discourse.system_user) - assigner.unassign(silent: true) - end - return unless SiteSetting.assigns_by_staff_mention if post.user && post.topic && post.user.staff? diff --git a/plugin.rb b/plugin.rb index 2e68ee9..2f43850 100644 --- a/plugin.rb +++ b/plugin.rb @@ -174,6 +174,13 @@ after_initialize do ::TopicAssigner.auto_assign(post, force: true) end + on(:topic_closed) do |topic| + if SiteSetting.unassign_on_close + assigner = ::TopicAssigner.new(topic, Discourse.system_user) + assigner.unassign(silent: true) + end + end + on(:move_to_inbox) do |info| if SiteSetting.unassign_on_group_archive && info[:group] if topic = info[:topic]