gitlab-org--gitlab-foss/app/services/projects/group_links/create_service.rb

26 lines
664 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-11-01 14:08:18 +00:00
module Projects
module GroupLinks
class CreateService < BaseService
def execute(group)
return error('Not Found', 404) unless group && can?(current_user, :read_namespace, group)
2017-11-01 14:08:18 +00:00
link = project.project_group_links.new(
2017-11-01 14:08:18 +00:00
group: group,
group_access: params[:link_group_access],
expires_at: params[:expires_at]
)
if link.save
success(link: link)
else
error(link.errors.full_messages.to_sentence, 409)
end
2017-11-01 14:08:18 +00:00
end
end
end
end
Projects::GroupLinks::CreateService.prepend_if_ee('EE::Projects::GroupLinks::CreateService')