2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Mattermost
|
|
|
|
class CreateTeamService < ::BaseService
|
|
|
|
def initialize(group, current_user)
|
2021-04-29 21:17:54 +05:30
|
|
|
@group = group
|
|
|
|
@current_user = current_user
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def execute
|
|
|
|
# The user that creates the team will be Team Admin
|
2021-09-04 01:27:46 +05:30
|
|
|
::Mattermost::Team.new(current_user).create(@group.mattermost_team_params)
|
|
|
|
rescue ::Mattermost::ClientError => e
|
2017-08-17 22:00:37 +05:30
|
|
|
@group.errors.add(:mattermost_team, e.message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|