diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 13:16:36 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-11-18 13:16:36 +0000 |
commit | 311b0269b4eb9839fa63f80c8d7a58f32b8138a0 (patch) | |
tree | 07e7870bca8aed6d61fdcc810731c50d2c40af47 /app/services/groups | |
parent | 27909cef6c4170ed9205afa7426b8d3de47cbb0c (diff) | |
download | gitlab-ce-311b0269b4eb9839fa63f80c8d7a58f32b8138a0.tar.gz |
Add latest changes from gitlab-org/gitlab@14-5-stable-eev14.5.0-rc42
Diffstat (limited to 'app/services/groups')
-rw-r--r-- | app/services/groups/create_service.rb | 12 | ||||
-rw-r--r-- | app/services/groups/import_export/import_service.rb | 2 | ||||
-rw-r--r-- | app/services/groups/transfer_service.rb | 19 |
3 files changed, 21 insertions, 12 deletions
diff --git a/app/services/groups/create_service.rb b/app/services/groups/create_service.rb index f900927793a..da3cebc2e6d 100644 --- a/app/services/groups/create_service.rb +++ b/app/services/groups/create_service.rb @@ -6,6 +6,7 @@ module Groups @current_user = user @params = params.dup @chat_team = @params.delete(:create_chat_team) + @create_event = @params.delete(:create_event) end def execute @@ -42,15 +43,26 @@ module Groups end end + after_create_hook + @group end private + attr_reader :create_event + def after_build_hook(group, params) # overridden in EE end + def after_create_hook + if group.persisted? && group.root? + delay = Namespaces::InviteTeamEmailService::DELIVERY_DELAY_IN_MINUTES + Namespaces::InviteTeamEmailWorker.perform_in(delay, group.id, current_user.id) + end + end + def remove_unallowed_params params.delete(:default_branch_protection) unless can?(current_user, :create_group_with_default_branch_protection) params.delete(:allow_mfa_for_subgroups) diff --git a/app/services/groups/import_export/import_service.rb b/app/services/groups/import_export/import_service.rb index f9db552f743..c8c2124078d 100644 --- a/app/services/groups/import_export/import_service.rb +++ b/app/services/groups/import_export/import_service.rb @@ -14,7 +14,7 @@ module Groups def async_execute group_import_state = GroupImportState.safe_find_or_create_by!(group: group, user: current_user) - jid = GroupImportWorker.perform_async(current_user.id, group.id) + jid = GroupImportWorker.with_status.perform_async(current_user.id, group.id) if jid.present? group_import_state.update!(jid: jid) diff --git a/app/services/groups/transfer_service.rb b/app/services/groups/transfer_service.rb index 334083a859f..cd89eb799dc 100644 --- a/app/services/groups/transfer_service.rb +++ b/app/services/groups/transfer_service.rb @@ -175,21 +175,18 @@ module Groups end def refresh_project_authorizations - ProjectAuthorization.where(project_id: @group.all_projects.select(:id)).delete_all # rubocop: disable CodeReuse/ActiveRecord + projects_to_update = Set.new - # refresh authorized projects for current_user immediately - current_user.refresh_authorized_projects - - # schedule refreshing projects for all the members of the group - @group.refresh_members_authorized_projects + # All projects in this hierarchy need to have their project authorizations recalculated + @group.all_projects.each_batch { |prjs| projects_to_update.merge(prjs.ids) } # rubocop: disable CodeReuse/ActiveRecord # When a group is transferred, it also affects who gets access to the projects shared to # the subgroups within its hierarchy, so we also schedule jobs that refresh authorizations for all such shared projects. - project_group_shares_within_the_hierarchy = ProjectGroupLink.in_group(group.self_and_descendants.select(:id)) - - project_group_shares_within_the_hierarchy.find_each do |project_group_link| - AuthorizedProjectUpdate::ProjectRecalculateWorker.perform_async(project_group_link.project_id) + ProjectGroupLink.in_group(@group.self_and_descendants.select(:id)).each_batch do |project_group_links| + projects_to_update.merge(project_group_links.pluck(:project_id)) # rubocop: disable CodeReuse/ActiveRecord end + + AuthorizedProjectUpdate::ProjectAccessChangedService.new(projects_to_update.to_a).execute unless projects_to_update.empty? end def raise_transfer_error(message) @@ -199,7 +196,7 @@ module Groups def localized_error_messages { database_not_supported: s_('TransferGroup|Database is not supported.'), - namespace_with_same_path: s_('TransferGroup|The parent group already has a subgroup with the same path.'), + namespace_with_same_path: s_('TransferGroup|The parent group already has a subgroup or a project with the same path.'), group_is_already_root: s_('TransferGroup|Group is already a root group.'), same_parent_as_current: s_('TransferGroup|Group is already associated to the parent group.'), invalid_policies: s_("TransferGroup|You don't have enough permissions."), |