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

update_service.rb « group_links « projects « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 475ab17f1a17662d20b6cb040cd1bc345f600b21 (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
37
38
39
40
41
42
43
# frozen_string_literal: true

module Projects
  module GroupLinks
    class UpdateService < BaseService
      def initialize(group_link, user = nil)
        super(group_link.project, user)

        @group_link = group_link
      end

      def execute(group_link_params)
        group_link.update!(group_link_params)

        refresh_authorizations if requires_authorization_refresh?(group_link_params)
      end

      private

      attr_reader :group_link

      def refresh_authorizations
        if Feature.enabled?(:specialized_worker_for_project_share_update_auth_recalculation)
          AuthorizedProjectUpdate::ProjectRecalculateWorker.perform_async(project.id)

          # Until we compare the inconsistency rates of the new specialized worker and
          # the old approach, we still run AuthorizedProjectsWorker
          # but with some delay and lower urgency as a safety net.
          group_link.group.refresh_members_authorized_projects(
            blocking: false,
            priority: UserProjectAccessChangedService::LOW_PRIORITY
          )
        else
          group_link.group.refresh_members_authorized_projects
        end
      end

      def requires_authorization_refresh?(params)
        params.include?(:group_access)
      end
    end
  end
end