2020-06-03 02:08:34 -04:00
|
|
|
# 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)
|
|
|
|
|
2021-06-22 15:11:50 -04:00
|
|
|
refresh_authorizations if requires_authorization_refresh?(group_link_params)
|
2020-06-03 02:08:34 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :group_link
|
|
|
|
|
2021-06-22 15:11:50 -04:00
|
|
|
def refresh_authorizations
|
2021-10-01 14:09:44 -04:00
|
|
|
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
|
|
|
|
)
|
2021-06-22 15:11:50 -04:00
|
|
|
end
|
|
|
|
|
2020-06-03 02:08:34 -04:00
|
|
|
def requires_authorization_refresh?(params)
|
|
|
|
params.include?(:group_access)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|