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

group_private_service.rb « destroy « todos « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d7ecbb952aa08e752edcf4a6e0d4d66cf8465cda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true

module Todos
  module Destroy
    class GroupPrivateService < ::Todos::Destroy::BaseService
      extend ::Gitlab::Utils::Override

      attr_reader :group

      # rubocop: disable CodeReuse/ActiveRecord
      def initialize(group_id)
        @group = Group.find_by(id: group_id)
      end
      # rubocop: enable CodeReuse/ActiveRecord

      private

      override :todos
      # rubocop: disable CodeReuse/ActiveRecord
      def todos
        Todo.where(group_id: group.id)
      end
      # rubocop: enable CodeReuse/ActiveRecord

      override :authorized_users
      def authorized_users
        group.direct_and_indirect_users.select(:id)
      end

      override :todos_to_remove?
      def todos_to_remove?
        group&.private?
      end
    end
  end
end