Welcome to mirror list, hosted at ThFree Co, Russian Federation.

access.rb « presenters « slash_commands « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 56a960c9bbf309ffe49224a573b397ae2ab78185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# frozen_string_literal: true

module Gitlab
  module SlashCommands
    module Presenters
      class Access < Presenters::Base
        def access_denied(project)
          ephemeral_response(text: <<~MESSAGE)
            You are not allowed to perform the given chatops command. Most
            likely you do not have access to the GitLab project for this chatops
            integration.

            The GitLab project for this chatops integration can be found at
            #{url_for(project)}.
          MESSAGE
        end

        def generic_access_denied
          ephemeral_response(text: 'You are not allowed to perform the given chatops command.')
        end

        def deactivated
          ephemeral_response(text: <<~MESSAGE)
            You are not allowed to perform the given ChatOps command. Most likely
            your #{Gitlab.config.gitlab.url} account needs to be reactivated.

            Please log back in from a web browser to reactivate your account at #{Gitlab.config.gitlab.url}
          MESSAGE
        end

        def not_found
          ephemeral_response(text: "404 not found! GitLab couldn't find what you were looking for! :boom:")
        end

        def authorize
          message =
            if resource
              ":wave: Hi there! Before I do anything for you, please [connect your GitLab account](#{resource})."
            else
              ":sweat_smile: Couldn't identify you, nor can I authorize you!"
            end

          ephemeral_response(text: message)
        end

        def confirm(url)
          text = [
            _("To ensure the highest security standards, we verify the source of all slash commands."),
            Kernel.format(_("Please confirm the request by accessing %{url} through a web browser."),
              url: "<#{url}|this link>"),
            _("Upon successful validation, you're granted access to slash commands.")
          ].join("\n\n")

          ephemeral_response(text: text)
        end
      end
    end
  end
end