summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2016-11-15 09:55:56 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-11-17 21:34:23 +0100
commit106b1e39c0d00f25e34dda0eba962c8cf1d43f1b (patch)
treee7033c7543c697bec6612a294925c2e3456ecbd7 /app/models
parent53271b486d296fae2e290d6948a05aeb47dbea89 (diff)
downloadgitlab-ce-106b1e39c0d00f25e34dda0eba962c8cf1d43f1b.tar.gz
First steps on refactoring Mattermost Slash commands
Now, each subcommand has its own service, plus I've introduced presenters to be able to delegate the generation of the views.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project_services/mattermost_chat_service.rb25
1 files changed, 2 insertions, 23 deletions
diff --git a/app/models/project_services/mattermost_chat_service.rb b/app/models/project_services/mattermost_chat_service.rb
index 01ff6b0f8b4..5e9f4d255b6 100644
--- a/app/models/project_services/mattermost_chat_service.rb
+++ b/app/models/project_services/mattermost_chat_service.rb
@@ -33,31 +33,10 @@ class MattermostChatService < ChatService
end
def trigger(params)
- return nil unless valid_token?(params[:token])
-
- user = find_chat_user(params)
- return authorize_chat_name(params) unless user
+ user = ChatNames::FindUserService.new(chat_names, params).execute
+ return Mattermost::Presenter.authorize_chat_name(params) unless user
Mattermost::CommandService.new(project, user, params.slice(:command, :text)).
execute
end
-
- private
-
- def find_chat_user(params)
- params = params.slice(:team_id, :user_id)
- ChatNames::FindUserService.
- new(chat_names, params).
- execute
- end
-
- def authorize_chat_name(params)
- params = params.slice(:team_id, :team_domain, :user_id, :user_name)
- url = ChatNames::AuthorizeUserService.new(self, params).execute
-
- {
- response_type: :ephemeral,
- message: "You are not authorized. Click this [link](#{url}) to authorize."
- }
- end
end