Skip to content
This repository was archived by the owner on Jul 14, 2025. It is now read-only.

Commit 06985c8

Browse files
committed
DEV: use argument instead of instance variable
1 parent a024e26 commit 06985c8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

plugin.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -887,11 +887,13 @@ module ::DiscourseAssign
887887
Assignment.active_for_group(group).destroy_all
888888
end
889889

890-
add_filter_custom_filter("assigned") do |scope, filter_values|
890+
add_filter_custom_filter("assigned") do |scope, filter_values, guardian|
891+
return if !guardian.can_assign? || filter_values.blank?
892+
891893
user_or_group_name = filter_values.compact.first
892894

893-
return scope if user_or_group_name.blank?
894-
895+
return if user_or_group_name.blank?
896+
895897
if user_id = User.find_by_username(user_or_group_name)&.id
896898
scope.where(<<~SQL, user_id)
897899
topics.id IN (SELECT a.topic_id FROM assignments a WHERE a.assigned_to_id = ? AND a.assigned_to_type = 'User' AND a.active)
@@ -900,8 +902,6 @@ module ::DiscourseAssign
900902
scope.where(<<~SQL, group_id)
901903
topics.id IN (SELECT a.topic_id FROM assignments a WHERE a.assigned_to_id = ? AND a.assigned_to_type = 'Group' AND a.active)
902904
SQL
903-
else
904-
scope
905905
end
906906
end
907907

@@ -913,7 +913,7 @@ module ::DiscourseAssign
913913

914914
register_search_advanced_filter(/in:unassigned/) do |posts|
915915
return if !@guardian.can_assign?
916-
916+
917917
posts.where("topics.id NOT IN (SELECT a.topic_id FROM assignments a WHERE a.active)")
918918
end
919919

0 commit comments

Comments
 (0)