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:
Diffstat (limited to 'app/models/integrations/mattermost_slash_commands.rb')
-rw-r--r--app/models/integrations/mattermost_slash_commands.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/models/integrations/mattermost_slash_commands.rb b/app/models/integrations/mattermost_slash_commands.rb
index 9554dec4168..29ed563a902 100644
--- a/app/models/integrations/mattermost_slash_commands.rb
+++ b/app/models/integrations/mattermost_slash_commands.rb
@@ -4,6 +4,8 @@ module Integrations
class MattermostSlashCommands < BaseSlashCommands
include Ci::TriggersHelper
+ MATTERMOST_URL = '%{ORIGIN}/%{TEAM}/channels/%{CHANNEL}'
+
field :token,
type: :password,
non_empty_password_title: -> { s_('ProjectService|Enter new token') },
@@ -41,6 +43,21 @@ module Integrations
[[], e.message]
end
+ def redirect_url(team, channel, url)
+ return if Gitlab::UrlBlocker.blocked_url?(url, schemes: %w[http https], enforce_sanitization: true)
+
+ origin = Addressable::URI.parse(url).origin
+ format(MATTERMOST_URL, ORIGIN: origin, TEAM: team, CHANNEL: channel)
+ end
+
+ def confirmation_url(command_id, params)
+ team, channel, response_url = params.values_at(:team_domain, :channel_name, :response_url)
+
+ Rails.application.routes.url_helpers.project_integrations_slash_commands_url(
+ project, command_id: command_id, integration: to_param, team: team, channel: channel, response_url: response_url
+ )
+ end
+
private
def command(params)