force assign on mention

This commit is contained in:
Sam Saffron 2017-02-20 10:44:56 -05:00
parent 4ec3c1a423
commit 5da7ce9e0f
1 changed files with 6 additions and 6 deletions

View File

@ -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