Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2017-02-20 15:41:50 +0300
committerZ.J. van de Weg <git@zjvandeweg.nl>2017-02-20 15:41:50 +0300
commit444d71e043eb19979ec1b08504b2760910cb2a47 (patch)
treeeae73ba8a12de1a84faee800fae9749b70ed1b78 /app/services/mattermost
parent549fc3469790da388035de713294f335fbfb4fb5 (diff)
Transactional mattermost team creation
Before this commit, but still on this feature branch, the creation of mattermost teams where a background job. However, it was decided it was better that these happened as transaction so feedback could be displayed to the user.
Diffstat (limited to 'app/services/mattermost')
-rw-r--r--app/services/mattermost/create_team_service.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/services/mattermost/create_team_service.rb b/app/services/mattermost/create_team_service.rb
new file mode 100644
index 00000000000..199d15aee92
--- /dev/null
+++ b/app/services/mattermost/create_team_service.rb
@@ -0,0 +1,15 @@
+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
+ response = Mattermost::Team.new(current_user).create(@group)
+ @group.build_chat_team(name: response['name'], team_id: response['id'])
+ rescue Mattermost::ClientError => e
+ @group.errors.add(:chat_team, e.message)
+ end
+ end
+end