2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Projects
|
|
|
|
module GroupLinks
|
|
|
|
class CreateService < BaseService
|
|
|
|
def execute(group)
|
2019-03-13 22:55:13 +05:30
|
|
|
return error('Not Found', 404) unless group && can?(current_user, :read_namespace, group)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2019-03-13 22:55:13 +05:30
|
|
|
link = project.project_group_links.new(
|
2018-03-17 18:26:18 +05:30
|
|
|
group: group,
|
|
|
|
group_access: params[:link_group_access],
|
|
|
|
expires_at: params[:expires_at]
|
|
|
|
)
|
2019-03-13 22:55:13 +05:30
|
|
|
|
|
|
|
if link.save
|
|
|
|
success(link: link)
|
|
|
|
else
|
|
|
|
error(link.errors.full_messages.to_sentence, 409)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|