2017-02-20 07:41:50 -05: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 14:34:29 -05:00
|
|
|
Mattermost::Team.new(current_user).create(@group.mattermost_team_params)
|
2017-02-20 07:41:50 -05:00
|
|
|
rescue Mattermost::ClientError => e
|
2017-03-01 14:34:29 -05:00
|
|
|
@group.errors.add(:mattermost_team, e.message)
|
2017-02-20 07:41:50 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|