2016-03-16 22:44:33 +00:00
|
|
|
module Groups
|
|
|
|
class CreateService < Groups::BaseService
|
2016-03-17 22:42:46 +00:00
|
|
|
def initialize(user, params = {})
|
|
|
|
@current_user, @params = user, params.dup
|
|
|
|
@group = Group.new(@params)
|
2016-03-16 22:44:33 +00:00
|
|
|
end
|
|
|
|
|
2016-03-17 22:42:46 +00:00
|
|
|
def execute
|
|
|
|
return @group unless visibility_allowed_for_user?(@params[:visibility_level])
|
|
|
|
@group.name = @group.path.dup unless @group.name
|
|
|
|
@group.save
|
|
|
|
@group.add_owner(@current_user)
|
|
|
|
@group
|
2016-03-16 22:44:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|