2018-07-17 16:50:37 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-20 12:41:50 +00:00
|
|
|
module Mattermost
|
|
|
|
class CreateTeamService < ::BaseService
|
|
|
|
def initialize(group, current_user)
|
|
|
|
@group, @current_user = group, current_user
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
# The user that creates the team will be Team Admin
|
2017-03-01 19:34:29 +00:00
|
|
|
Mattermost::Team.new(current_user).create(@group.mattermost_team_params)
|
2017-02-20 12:41:50 +00:00
|
|
|
rescue Mattermost::ClientError => e
|
2017-03-01 19:34:29 +00:00
|
|
|
@group.errors.add(:mattermost_team, e.message)
|
2017-02-20 12:41:50 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|