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

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

39 lines
958 B
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
module Groups
module GroupLinks
2021-04-29 21:17:54 +05:30
class CreateService < Groups::BaseService
2022-07-16 23:28:13 +05:30
include GroupLinkable
2019-12-26 22:10:19 +05:30
2022-07-16 23:28:13 +05:30
def initialize(group, shared_with_group, user, params)
@shared_with_group = shared_with_group
2019-12-26 22:10:19 +05:30
2022-07-16 23:28:13 +05:30
super(group, user, params)
2019-12-26 22:10:19 +05:30
end
2021-09-04 01:27:46 +05:30
private
2022-07-16 23:28:13 +05:30
delegate :root_ancestor, to: :group
2021-09-04 01:27:46 +05:30
2022-07-16 23:28:13 +05:30
def valid_to_create?
can?(current_user, :admin_group_member, group) &&
can?(current_user, :read_group, shared_with_group) &&
sharing_allowed?
2021-09-04 01:27:46 +05:30
end
2022-07-16 23:28:13 +05:30
def build_link
@link = GroupGroupLink.new(
shared_group: group,
shared_with_group: shared_with_group,
group_access: params[:shared_group_access],
expires_at: params[:expires_at]
)
2021-09-04 01:27:46 +05:30
end
2022-07-16 23:28:13 +05:30
def setup_authorizations
shared_with_group.refresh_members_authorized_projects(blocking: false, direct_members_only: true)
2021-09-04 01:27:46 +05:30
end
2019-12-26 22:10:19 +05:30
end
end
end