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 |
# File 'app/services/groups/create_service.rb', line 5 def initialize(user, params = {}) @current_user, @params = user, params.dup @chat_team = @params.delete(:create_chat_team) end |
Instance Method Details
#execute ⇒ Object
10 11 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 |
# File 'app/services/groups/create_service.rb', line 10 def execute remove_unallowed_params set_visibility_level @group = Group.new(params) after_build_hook(@group, params) 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 if @group.save @group.add_owner(current_user) add_settings_record end @group end |