diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-02 21:26:53 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-02 21:26:53 +0000 |
commit | b30f7e36de53f94df4022815d3fbdadc4368a7e3 (patch) | |
tree | 422cc3db247e7d5e9d6dcb9cc40618b863cd64ce /app/services | |
parent | c8edb9de30c95e9e715a1e31e7667f94fb7f3dec (diff) | |
download | gitlab-ce-b30f7e36de53f94df4022815d3fbdadc4368a7e3.tar.gz |
Add latest changes from gitlab-org/security/gitlab@14-1-stable-ee
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/todos/allowed_target_filter_service.rb | 18 |
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 |