summaryrefslogtreecommitdiff
path: root/lib/mattermost/session.rb
diff options
context:
space:
mode:
authorZ.J. van de Weg <git@zjvandeweg.nl>2016-12-13 19:52:41 +0100
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-12-16 12:21:09 +0100
commit87d160634dfdaacd0dc382c26932786382d1be34 (patch)
tree3eb381dd13f1ebd0acdf6c5364f9c2639e057b26 /lib/mattermost/session.rb
parentdd385c7c3d3046da18c6c251bce25afab1129662 (diff)
downloadgitlab-ce-87d160634dfdaacd0dc382c26932786382d1be34.tar.gz
Base work for auto config MM slash commands
Diffstat (limited to 'lib/mattermost/session.rb')
-rw-r--r--lib/mattermost/session.rb13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb
index 81964666757..cc4cb1f4f12 100644
--- a/lib/mattermost/session.rb
+++ b/lib/mattermost/session.rb
@@ -20,6 +20,7 @@ module Mattermost
attr_accessor :current_resource_owner
def initialize(uri, current_user)
+ uri = normalize_uri(uri)
self.class.base_uri(uri)
@current_resource_owner = current_user
@@ -31,6 +32,8 @@ module Mattermost
destroy
result
+ rescue Errno::ECONNREFUSED
+ raise NoSessionError
end
# Next methods are needed for Doorkeeper
@@ -67,11 +70,11 @@ module Mattermost
end
def destroy
- post('/api/v3/users/logout')
+ post('/users/logout')
end
def oauth_uri
- response = get("/api/v3/oauth/gitlab/login", follow_redirects: false)
+ response = get("/oauth/gitlab/login", follow_redirects: false)
return unless 300 <= response.code && response.code < 400
redirect_uri = response.headers['location']
@@ -100,5 +103,11 @@ module Mattermost
def post(path, options = {})
self.class.post(path, options)
end
+
+ def normalize_uri(uri)
+ uri << '/' unless uri.end_with?('/')
+
+ uri << 'api/v3'
+ end
end
end