Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-30 18:14:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-30 18:14:17 +0300
commit3fe9588b1c1c4fb58f8ba8e9c27244fc2fc1c103 (patch)
treed19448d010ff9d58fed14846736ee358fb6b3327 /app/services/groups
parentad8eea383406037a207c80421e6e4bfa357f8044 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/services/groups')
-rw-r--r--app/services/groups/group_links/create_service.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/services/groups/group_links/create_service.rb b/app/services/groups/group_links/create_service.rb
new file mode 100644
index 00000000000..2ce53fcfe4a
--- /dev/null
+++ b/app/services/groups/group_links/create_service.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+module Groups
+ module GroupLinks
+ class CreateService < BaseService
+ def execute(shared_group)
+ unless group && shared_group &&
+ can?(current_user, :admin_group, shared_group) &&
+ can?(current_user, :read_group, group)
+ return error('Not Found', 404)
+ end
+
+ link = GroupGroupLink.new(
+ shared_group: shared_group,
+ shared_with_group: group,
+ group_access: params[:shared_group_access],
+ expires_at: params[:expires_at]
+ )
+
+ if link.save
+ group.refresh_members_authorized_projects
+ success(link: link)
+ else
+ error(link.errors.full_messages.to_sentence, 409)
+ end
+ end
+ end
+ end
+end