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]