summaryrefslogtreecommitdiff
path: root/app/services/groups/group_links/destroy_service.rb
blob: 6835b6c46378c176cc275f3df3d531d625607b43 (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
# frozen_string_literal: true

module Groups
  module GroupLinks
    class DestroyService < BaseService
      def execute(one_or_more_links)
        links = Array(one_or_more_links)

        if GroupGroupLink.delete(links)
          Gitlab::AppLogger.info(
            "GroupGroupLinks with ids: #{links.map(&:id)} have been deleted.")

          groups_to_refresh = links.map(&:shared_with_group)
          groups_to_refresh.uniq.each do |group|
            group.refresh_members_authorized_projects
          end
        else
          Gitlab::AppLogger.info(
            "Failed to delete GroupGroupLinks with ids: #{links.map(&:id)}.")
        end
      end
    end
  end
end