debian-mirror-gitlab/app/services/groups/group_links/destroy_service.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
989 B
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
module Groups
module GroupLinks
2023-03-04 22:38:38 +05:30
class DestroyService < ::Groups::BaseService
2020-06-23 00:09:42 +05:30
def execute(one_or_more_links, skip_authorization: false)
unless skip_authorization || group && can?(current_user, :admin_group_member, group)
return error('Not Found', 404)
end
2019-12-26 22:10:19 +05:30
links = Array(one_or_more_links)
2020-03-13 15:44:24 +05:30
if GroupGroupLink.delete(links)
Gitlab::AppLogger.info(
"GroupGroupLinks with ids: #{links.map(&:id)} have been deleted.")
2019-12-26 22:10:19 +05:30
groups_to_refresh = links.map(&:shared_with_group)
groups_to_refresh.uniq.each do |group|
2022-08-13 15:12:31 +05:30
next if Feature.enabled?(:skip_group_share_unlink_auth_refresh, group.root_ancestor)
2023-04-23 21:23:45 +05:30
group.refresh_members_authorized_projects(direct_members_only: true)
2019-12-26 22:10:19 +05:30
end
2020-03-13 15:44:24 +05:30
else
Gitlab::AppLogger.info(
"Failed to delete GroupGroupLinks with ids: #{links.map(&:id)}.")
2019-12-26 22:10:19 +05:30
end
end
end
end
end