From 5da7ce9e0f11d42ba0c03726009a8210d12903a5 Mon Sep 17 00:00:00 2001 From: Sam Saffron Date: Mon, 20 Feb 2017 10:44:56 -0500 Subject: [PATCH] force assign on mention --- plugin.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugin.rb b/plugin.rb index 852dc2b..6c7ae80 100644 --- a/plugin.rb +++ b/plugin.rb @@ -45,12 +45,12 @@ SQL puts "#{assigned} topics where automatically assigned to staff members" end - def self.auto_assign(post) + def self.auto_assign(post, force: false) return unless SiteSetting.assigns_by_staff_mention - if post.user && post.topic && post.user.staff? && post.topic.custom_fields["assigned_to_id"].nil? - - if is_last_staff_post?(post) && user = mentioned_staff(post) + if post.user && post.topic && post.user.staff? + can_assign = force || post.topic.custom_fields["assigned_to_id"].nil? + if can_assign && is_last_staff_post?(post) && user = mentioned_staff(post) assigner = new(post.topic, post.user) assigner.assign(user, silent: true) end @@ -308,11 +308,11 @@ SQL on(:post_created) do |post| - ::TopicAssigner.auto_assign(post) + ::TopicAssigner.auto_assign(post, force: true) end on(:post_edited) do |post, topic_changed| - ::TopicAssigner.auto_assign(post) + ::TopicAssigner.auto_assign(post, force: true) end end