Class: Groups::CreateService
- Inherits:
-
BaseService
- Object
- BaseService
- BaseService
- Groups::CreateService
- Defined in:
- app/services/groups/create_service.rb
Instance Attribute Summary
Attributes inherited from BaseService
#current_user, #group, #params
Attributes inherited from BaseService
#current_user, #params, #project
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(user, params = {}) ⇒ CreateService
constructor
A new instance of CreateService.
Methods included from BaseServiceUtility
#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level
Methods included from Gitlab::Allowable
Constructor Details
#initialize(user, params = {}) ⇒ CreateService
Returns a new instance of CreateService.
5 6 7 8 9 10 |
# File 'app/services/groups/create_service.rb', line 5 def initialize(user, params = {}) @current_user = user @params = params.dup @chat_team = @params.delete(:create_chat_team) @create_event = @params.delete(:create_event) end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/groups/create_service.rb', line 12 def execute remove_unallowed_params set_visibility_level @group = Group.new(params.except(*::NamespaceSetting.allowed_namespace_settings_params)) @group.build_namespace_settings handle_namespace_settings after_build_hook(@group, params) inherit_group_shared_runners_settings unless can_use_visibility_level? && can_create_group? return @group end @group.name ||= @group.path.dup if create_chat_team? response = ::Mattermost::CreateTeamService.new(@group, current_user).execute return @group if @group.errors.any? @group.build_chat_team(name: response['name'], team_id: response['id']) end Gitlab::Database::QueryAnalyzers::PreventCrossDatabaseModification.temporary_ignore_tables_in_transaction( %w[routes redirect_routes], url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/424281' ) do Group.transaction do if @group.save @group.add_owner(current_user) Integration.create_from_active_default_integrations(@group, :group_id) end end end after_create_hook @group end |