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>2016-12-16 14:57:43 +0300
committerZ.J. van de Weg <git@zjvandeweg.nl>2016-12-16 16:16:10 +0300
commit475a4dc34dd775147dafebcf1b4d648bf2b9aeec (patch)
treeafcc70bc7e0116cb00d61ab4624ef09a5dffb6ef /lib/mattermost
parent0045996728308bcb7643618ab48efb7e04e7d4bf (diff)
parent166ae89dfa36b8e844e58e61e3838200c4ab8ab7 (diff)
Merge branch 'zj-mattermost-session' into zj-mattermost-slash-config
Diffstat (limited to 'lib/mattermost')
-rw-r--r--lib/mattermost/command.rb18
-rw-r--r--lib/mattermost/session.rb14
2 files changed, 15 insertions, 17 deletions
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb
index b6446935eb6..108a2a47a4b 100644
--- a/lib/mattermost/command.rb
+++ b/lib/mattermost/command.rb
@@ -1,24 +1,18 @@
module Mattermost
class Command < Session
- def self.all(team_id)
- get("/teams/#{team_id}/commands/list_team_commands").parsed_response
- end
-
- # params should be a hash, which supplies _at least_:
- # - trigger => The slash command, no spaces, cannot start with a /
- # - url => What is the URL to trigger here?
- # - icon_url => Supply a link to the icon
- def self.create(team_id, params)
+ def self.create(team_id, trigger: 'gitlab', url:, icon_url:)
command = {
auto_complete: true,
auto_complete_desc: 'List all available commands',
auto_complete_hint: '[help]',
description: 'Perform common operations on GitLab',
- display_name: 'GitLab',
+ display_name: 'GitLab Slash Commands',
method: 'P',
user_name: 'GitLab',
- trigger: 'gitlab',
- }.merge(params)
+ trigger: trigger,
+ url: url,
+ icon_url: icon_url
+ }
response = post( "/teams/#{team_id}/commands/create", body: command.to_json)
diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb
index 15bf95a38c9..ee031541012 100644
--- a/lib/mattermost/session.rb
+++ b/lib/mattermost/session.rb
@@ -21,6 +21,8 @@ module Mattermost
def initialize(uri, current_user)
uri = normalize_uri(uri)
+
+ # Sets the base uri for HTTParty, so we can use paths
self.class.base_uri(uri)
@current_resource_owner = current_user
@@ -28,12 +30,14 @@ module Mattermost
def with_session
raise NoSessionError unless create
- result = yield
- destroy
- result
- rescue Errno::ECONNREFUSED
- raise NoSessionError
+ begin
+ yield
+ rescue Errno::ECONNREFUSED
+ raise NoSessionError
+ ensure
+ destroy
+ end
end
# Next methods are needed for Doorkeeper