From 8ee1cbd697473619f539c1ec5fcab479381c690f Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 26 Feb 2018 16:15:22 -0500 Subject: [PATCH] FIX: Unassign topics if there are no more flags to handle --- plugin.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugin.rb b/plugin.rb index cd7eec3..b203a40 100644 --- a/plugin.rb +++ b/plugin.rb @@ -206,6 +206,16 @@ after_initialize do end end + # Unassign if there are no more flags in the topic + on(:flag_reviewed) do |post| + if SiteSetting.assign_locks_flags? && + FlagQuery.flagged_post_actions(topic_id: post.topic_id).count == 0 + + assigner = ::TopicAssigner.new(post.topic, Discourse.system_user) + assigner.unassign + end + end + on(:move_to_inbox) do |info| if SiteSetting.unassign_on_group_archive && info[:group] if topic = info[:topic]