summaryrefslogtreecommitdiff
path: root/app/services/groups/create_service.rb
blob: f605ccca81b006e96be7e08240bc2b0d90f346cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module Groups
  class CreateService < Groups::BaseService
    def initialize(user, params = {})
      @current_user, @params = user, params.dup
    end

    def execute
      @group = Group.new(params)

      return @group unless visibility_allowed_for_user?

      @group.name = @group.path.dup unless @group.name
      @group.save
      @group.add_owner(current_user)
      @group
    end
  end
end