diff options
author | James Fargher <proglottis@gmail.com> | 2019-02-21 00:29:48 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2019-02-21 00:29:48 +0300 |
commit | 2d19b1adef1fd880c3d49f307ff8d5317d31d94a (patch) | |
tree | 5c16a7ffb65801b8dd7ace152d0a9e0edee358ac /lib/gitlab/slash_commands/presenters | |
parent | ee0a007f8f47ba1c8117f2e9130663461181a145 (diff) |
Move ChatOps to Core
ChatOps used to be in the Ultimate tier.
Diffstat (limited to 'lib/gitlab/slash_commands/presenters')
-rw-r--r-- | lib/gitlab/slash_commands/presenters/error.rb | 17 | ||||
-rw-r--r-- | lib/gitlab/slash_commands/presenters/run.rb | 33 |
2 files changed, 50 insertions, 0 deletions
diff --git a/lib/gitlab/slash_commands/presenters/error.rb b/lib/gitlab/slash_commands/presenters/error.rb new file mode 100644 index 00000000000..442f8796338 --- /dev/null +++ b/lib/gitlab/slash_commands/presenters/error.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Gitlab + module SlashCommands + module Presenters + class Error < Presenters::Base + def initialize(message) + @message = message + end + + def message + ephemeral_response(text: @message) + end + end + end + end +end diff --git a/lib/gitlab/slash_commands/presenters/run.rb b/lib/gitlab/slash_commands/presenters/run.rb new file mode 100644 index 00000000000..c4bbc231464 --- /dev/null +++ b/lib/gitlab/slash_commands/presenters/run.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Gitlab + module SlashCommands + module Presenters + class Run < Presenters::Base + # rubocop: disable CodeReuse/ActiveRecord + def present(pipeline) + build = pipeline.builds.take + + if build && (responder = Chat::Responder.responder_for(build)) + in_channel_response(responder.scheduled_output) + else + unsupported_chat_service + end + end + # rubocop: enable CodeReuse/ActiveRecord + + def unsupported_chat_service + ephemeral_response(text: 'Sorry, this chat service is currently not supported by GitLab ChatOps.') + end + + def failed_to_schedule(command) + ephemeral_response( + text: 'The command could not be scheduled. Make sure that your ' \ + 'project has a .gitlab-ci.yml that defines a job with the ' \ + "name #{command.inspect}" + ) + end + end + end + end +end |