diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-07-28 12:58:20 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-07-28 12:58:20 +0300 |
commit | 850a22547ccb0969b3b013dcb891bff90b068d7f (patch) | |
tree | 93f28923f22fac22ed5ee2e94a7173fbcdd03259 /app | |
parent | 3109623d6e03ca1ac677ddbd69e5b8b20f82b65f (diff) | |
parent | d7062dd042f7dd773900ecf6ea79e1ca26592eb5 (diff) |
Merge branch 'zj-delete-mm-team' into 'master'
Remove Mattermost team with GitLab group
Closes #30023
See merge request !11362
Diffstat (limited to 'app')
-rw-r--r-- | app/models/chat_team.rb | 9 | ||||
-rw-r--r-- | app/services/groups/destroy_service.rb | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/app/models/chat_team.rb b/app/models/chat_team.rb index c52b6f15913..25ecf2d5937 100644 --- a/app/models/chat_team.rb +++ b/app/models/chat_team.rb @@ -3,4 +3,13 @@ class ChatTeam < ActiveRecord::Base validates :namespace, uniqueness: true belongs_to :namespace + + def remove_mattermost_team(current_user) + Mattermost::Team.new(current_user).destroy(team_id: team_id) + rescue Mattermost::ClientError => e + # Either the group is not found, or the user doesn't have the proper + # access on the mattermost instance. In the first case, we're done either way + # in the latter case, we can't recover by retrying, so we just log what happened + Rails.logger.error("Mattermost team deletion failed: #{e}") + end end diff --git a/app/services/groups/destroy_service.rb b/app/services/groups/destroy_service.rb index 80c51cb5a72..f565612a89d 100644 --- a/app/services/groups/destroy_service.rb +++ b/app/services/groups/destroy_service.rb @@ -21,6 +21,8 @@ module Groups DestroyService.new(group, current_user).execute end + group.chat_team&.remove_mattermost_team(current_user) + group.really_destroy! end end |