account_validation.rb 3.07 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
# frozen_string_literal: true

module Gitlab
  module Email
    module Message
      class AccountValidation
        include Gitlab::Email::Message::InProductMarketing::Helper
        include Gitlab::Routing

        attr_accessor :pipeline, :format

        def initialize(pipeline, format: :html)
          @pipeline = pipeline
          @format = format
        end

        def subject_line
          s_('AccountValidation|Fix your pipelines by validating your account')
        end

        def title
22
          s_("AccountValidation|Looks like you’ll need to validate your account to use free CI/CD minutes")
23 24 25
        end

        def body_line1
26
          s_("AccountValidation|In order to use free CI/CD minutes on shared runners, you'll need to validate your account using one of our verification options. If you prefer not to, you can run pipelines by bringing your own runners and disabling shared runners for your project.")
27 28 29 30
        end

        def body_line2
          format_options = strong_options.merge({ learn_more_link: learn_more_link })
31
          s_("AccountValidation|Verification is required to discourage and reduce the abuse on GitLab infrastructure. If you verify with a credit or debit card, %{strong_start}GitLab will not charge your card, it will only be used for validation.%{strong_end} %{learn_more_link}").html_safe % format_options
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
        end

        def cta_text
          s_('AccountValidation|Validate your account')
        end

        def cta2_text
          s_("AccountValidation|I'll bring my own runners")
        end

        def logo_path
          'mailers/in_product_marketing/verify-2.png'
        end

        def cta_link
47
          url = project_pipeline_validate_account_url(pipeline.project, pipeline)
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

          case format
          when :html
            ActionController::Base.helpers.link_to cta_text, url, target: '_blank', rel: 'noopener noreferrer'
          else
            [cta_text, url].join(' >> ')
          end
        end

        def cta2_link
          url = 'https://docs.gitlab.com/runner/install/'

          case format
          when :html
            ActionController::Base.helpers.link_to cta2_text, url, target: '_blank', rel: 'noopener noreferrer'
          else
            [cta2_text, url].join(' >> ')
          end
        end

        def learn_more_link
          link(s_('AccountValidation|Learn more.'), 'https://about.gitlab.com/blog/2021/05/17/prevent-crypto-mining-abuse/')
        end

        def unsubscribe
          parts = [
            s_('AccountValidation|If you no longer wish to receive marketing emails from us,'),
            s_('AccountValidation|you may %{unsubscribe_link} at any time.') % { unsubscribe_link: mailgun_unsubscribe_link }
          ]

          case format
          when :html
            parts.join(' ')
          else
            parts.join("\n" + ' ' * 16)
          end
        end

        private

        def mailgun_unsubscribe_link
          mailgun_unsubscribe_url = '%tag_unsubscribe_url%'

          link(s_('AccountValidation|unsubscribe'), mailgun_unsubscribe_url)
        end
      end
    end
  end
end