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
943 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 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
2023-04-23 21:23:45 +05:30
shared_with_group.refresh_members_authorized_projects(direct_members_only: true)
2021-09-04 01:27:46 +05:30
end
2019-12-26 22:10:19 +05:30
end
end
end