Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-08-04 00:09:39 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-08-04 00:09:39 +0300
commit4bf395cded929b1f2d2419079d8107604c9f930f (patch)
treed6edb3ab04e1a8241f9ac44ebb789cfc6ebaeff9 /app/services/todos
parent49058851264455c22a5ba00c8671b7d4cdfd8ee9 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/todos')
-rw-r--r--app/services/todos/allowed_target_filter_service.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/app/services/todos/allowed_target_filter_service.rb b/app/services/todos/allowed_target_filter_service.rb
new file mode 100644
index 00000000000..dfed616710b
--- /dev/null
+++ b/app/services/todos/allowed_target_filter_service.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Todos
+ class AllowedTargetFilterService
+ include Gitlab::Allowable
+
+ def initialize(todos, current_user)
+ @todos = todos
+ @current_user = current_user
+ end
+
+ def execute
+ Preloaders::UserMaxAccessLevelInProjectsPreloader.new(@todos.map(&:project).compact, @current_user).execute
+
+ @todos.select { |todo| can?(@current_user, :read_todo, todo) }
+ end
+ end
+end