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

allowed_target_filter_service.rb « todos « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dfed616710be35547a076e831ab087c6f379aa77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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