diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-17 21:09:07 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-04-17 21:09:07 +0000 |
commit | 848de49029934d840c047657fc00f79b51b979a0 (patch) | |
tree | cfd36aea071a8774ff7925cccb51772f6ec5aca3 | |
parent | 55bc011bc0f9e6102732d2694735a546738d6c5f (diff) | |
download | gitlab-ce-848de49029934d840c047657fc00f79b51b979a0.tar.gz |
Add latest changes from gitlab-org/gitlab@master
-rw-r--r-- | app/mailers/emails/service_desk.rb | 12 | ||||
-rw-r--r-- | app/mailers/previews/notify_preview.rb | 40 | ||||
-rw-r--r-- | app/views/notify/service_desk_verification_result_email.html.haml | 58 | ||||
-rw-r--r-- | app/views/notify/service_desk_verification_result_email.text.erb | 38 | ||||
-rw-r--r-- | doc/user/admin_area/settings/help_page.md | 15 | ||||
-rw-r--r-- | locale/gitlab.pot | 57 | ||||
-rw-r--r-- | spec/mailers/emails/service_desk_spec.rb | 30 |
7 files changed, 240 insertions, 10 deletions
diff --git a/app/mailers/emails/service_desk.rb b/app/mailers/emails/service_desk.rb index f2327239699..e75882073f2 100644 --- a/app/mailers/emails/service_desk.rb +++ b/app/mailers/emails/service_desk.rb @@ -86,6 +86,18 @@ module Emails email_with_layout(to: recipient, subject: subject) end + def service_desk_verification_result_email(service_desk_setting, recipient) + @service_desk_setting = service_desk_setting + @verification = @service_desk_setting.custom_email_verification + + subject = format(s_("Notify|Verification result for custom email %{email} for %{project_name}"), + email: @service_desk_setting.custom_email, + project_name: @service_desk_setting.project.name + ) + + email_with_layout(to: recipient, subject: subject) + end + private def setup_service_desk_mail(issue_id) diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb index f6c4b05ab39..510f35ee0d2 100644 --- a/app/mailers/previews/notify_preview.rb +++ b/app/mailers/previews/notify_preview.rb @@ -229,6 +229,36 @@ class NotifyPreview < ActionMailer::Preview end end + def service_desk_verification_result_email_for_verified_state + cleanup do + setup_service_desk_custom_email_objects + + custom_email_verification.update!(state: 1) + + Notify.service_desk_verification_result_email(service_desk_setting, 'owner@example.com').message + end + end + + def service_desk_verification_result_email_for_incorrect_token_error + service_desk_verification_result_email_for_error_state(error: :incorrect_token) + end + + def service_desk_verification_result_email_for_incorrect_from_error + service_desk_verification_result_email_for_error_state(error: :incorrect_from) + end + + def service_desk_verification_result_email_for_mail_not_received_within_timeframe_error + service_desk_verification_result_email_for_error_state(error: :mail_not_received_within_timeframe) + end + + def service_desk_verification_result_email_for_invalid_credentials_error + service_desk_verification_result_email_for_error_state(error: :invalid_credentials) + end + + def service_desk_verification_result_email_for_smtp_host_issue_error + service_desk_verification_result_email_for_error_state(error: :smtp_host_issue) + end + def merge_when_pipeline_succeeds_email Notify.merge_when_pipeline_succeeds_email(user.id, merge_request.id, user.id).message end @@ -263,6 +293,16 @@ class NotifyPreview < ActionMailer::Preview @project ||= Project.first end + def service_desk_verification_result_email_for_error_state(error:) + cleanup do + setup_service_desk_custom_email_objects + + custom_email_verification.update!(state: 2, error: error) + + Notify.service_desk_verification_result_email(service_desk_setting, 'owner@example.com').message + end + end + def setup_service_desk_custom_email_objects # Call accessors to ensure objects have been created custom_email_credential diff --git a/app/views/notify/service_desk_verification_result_email.html.haml b/app/views/notify/service_desk_verification_result_email.html.haml new file mode 100644 index 00000000000..d63177e4a42 --- /dev/null +++ b/app/views/notify/service_desk_verification_result_email.html.haml @@ -0,0 +1,58 @@ +- project_link = @service_desk_setting.project.web_url +- project_link_start = '<a href="%{project_link}" target="_blank" rel="noopener noreferrer" class="highlight">'.html_safe % { project_link: project_link } +- project_name = @service_desk_setting.project.human_name +- project_link_end = '</a>'.html_safe +- settings_link = edit_project_url(@service_desk_setting.project, anchor: 'js-service-desk') +- settings_link_start = '<a href="%{settings_link}" target="_blank" rel="noopener noreferrer" class="highlight">'.html_safe % { settings_link: settings_link } +- settings_link_end = '</a>'.html_safe +- strong_open = '<strong>'.html_safe +- strong_close = '</strong>'.html_safe +- email_address = @service_desk_setting.custom_email +- verify_email_address = @service_desk_setting.custom_email_address_for_verification +- code_open = '<code>'.html_safe +- code_end = '</code>'.html_safe + +%tr + %td.text-content + - if @verification.verified? + %h1{ :style => "margin-top:0;" } + = s_("Notify|Email successfully verified") + %p + = html_escape(s_('Notify|Your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end} was verified successfully.')) % { email_address: email_address, project_link_start: project_link_start, project_name: project_name, project_link_end: project_link_end, strong_open: strong_open, strong_close: strong_close } + %p + = html_escape(s_('Notify|To enable the custom email address, go to your %{settings_link_start}project\'s Service Desk settings page%{settings_link_end}.')) % { settings_link_start: settings_link_start, settings_link_end: settings_link_end } + - else + %h1{ :style => "margin-top:0;" } + = s_("Notify|Email could not be verified") + %p + = html_escape(s_('Notify|We could not verify your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end}.')) % { email_address: email_address, project_link_start: project_link_start, project_name: project_name, project_link_end: project_link_end, strong_open: strong_open, strong_close: strong_close } + - if @verification.smtp_host_issue? + %p + %b + = s_('Notify|SMTP host issue:') + = s_('Notify|We were not able to make a connection to the specified host or there was an SSL issue.') + - if @verification.invalid_credentials? + %p + %b + = s_('Notify|Invalid credentials:') + = s_('Notify|The given credentials (username and password) were rejected by the SMTP server.') + - if @verification.mail_not_received_within_timeframe? + %p + %b + = s_('Notify|Verification email not received within timeframe:') + = html_escape(s_('Notify|We did not receive the verification email we sent out to %{strong_open}%{email_address}%{strong_close} in time.')) % { email_address: verify_email_address, strong_open: strong_open, strong_close: strong_close } + %p + = s_('Notify|We wait for 30 minutes for messages to appear in your instance\'s Service Desk inbox.') + = s_('Notify|Please check that your service provider supports email subaddressing and that you have set up email forwarding correctly.') + - if @verification.incorrect_from? + %p + %b + = html_escape(s_('Notify|Incorrect %{code_open}From%{code_end} header:')) % { code_open: code_open, code_end: code_end } + = html_escape(s_('Notify|Check your forwarding settings and make sure the original email sender remains in the %{code_open}From%{code_end} header.')) % { code_open: code_open, code_end: code_end } + - if @verification.incorrect_token? + %p + %b + = s_('Notify|Incorrect verification token:') + = s_('Notify|We could not verify that we received the email we sent to your email inbox.') + %p + = html_escape(s_('Notify|To restart the verification process, go to your %{settings_link_start}project\'s Service Desk settings page%{settings_link_end}.')) % { settings_link_start: settings_link_start, settings_link_end: settings_link_end } diff --git a/app/views/notify/service_desk_verification_result_email.text.erb b/app/views/notify/service_desk_verification_result_email.text.erb new file mode 100644 index 00000000000..a78e3b19d1e --- /dev/null +++ b/app/views/notify/service_desk_verification_result_email.text.erb @@ -0,0 +1,38 @@ +<% project_name = @service_desk_setting.project.human_name %> +<% email_address = @service_desk_setting.custom_email %> +<% verify_email_address = @service_desk_setting.custom_email_address_for_verification %> + +<% if @verification.verified? %> + <%= s_("Notify|Email successfully verified") %> + + <%= s_('Notify|Your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end} was verified successfully.') % { email_address: email_address, project_link_start: '', project_name: project_name, project_link_end: '', strong_open: '', strong_close: '' } %> + + <%= s_('Notify|To enable the custom email address, go to your %{settings_link_start}project\'s Service Desk settings page%{settings_link_end}.') % { settings_link_start: '', settings_link_end: '' } %> +<% else %> + <%= s_("Notify|Email could not be verified") %> + + <%= s_('Notify|We could not verify your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end}.') % { email_address: email_address, project_link_start: '', project_name: project_name, project_link_end: '', strong_open: '', strong_close: '' } %> + + <% if @verification.smtp_host_issue? %> + <%= s_('Notify|SMTP host issue:') %> + <%= s_('Notify|We were not able to make a connection to the specified host or there was an SSL issue.') %> + <% elsif @verification.invalid_credentials? %> + <%= s_('Notify|Invalid credentials:') %> + <%= s_('Notify|The given credentials (username and password) were rejected by the SMTP server.') %> + <% elsif @verification.mail_not_received_within_timeframe? %> + <%= s_('Notify|Verification email not received within timeframe:') %> + <%= s_('Notify|We did not receive the verification email we sent out to %{strong_open}%{email_address}%{strong_close} in time.') % { email_address: verify_email_address, strong_open: '', strong_close: '' } %> + + <%= s_('Notify|We wait for 30 minutes for messages to appear in your instance\'s Service Desk inbox.') %> + + <%= s_('Notify|Please check that your service provider supports email subaddressing and that you have set up email forwarding correctly.') %> + <% elsif @verification.incorrect_from? %> + <%= s_('Notify|Incorrect %{code_open}From%{code_end} header:') % { code_open: '', code_end: '' } %> + <%= s_('Notify|Check your forwarding settings and make sure the original email sender remains in the %{code_open}From%{code_end} header.') % { code_open: '', code_end: '' } %> + <% elsif @verification.incorrect_token? %> + <%= s_('Notify|Incorrect verification token:') %> + <%= s_('Notify|We could not verify that we received the email we sent to your email inbox.') %> + <% end %> + + <%= s_('Notify|To restart the verification process, go to your %{settings_link_start}project\'s Service Desk settings page%{settings_link_end}.') % { settings_link_start: '', settings_link_end: '' } %> +<% end %> diff --git a/doc/user/admin_area/settings/help_page.md b/doc/user/admin_area/settings/help_page.md index 07d3ae83d74..5d9fc23aaff 100644 --- a/doc/user/admin_area/settings/help_page.md +++ b/doc/user/admin_area/settings/help_page.md @@ -71,14 +71,7 @@ You can specify a custom URL to which users are directed when they: > - [Feature flag `help_page_documentation_redirect`](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71737) removed in GitLab 14.4. > - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/71737) in GitLab 14.4. -The `/help` URL of a GitLab instance displays a basic version of the documentation sourced from the -[`doc` directory](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc) of GitLab. `/help` links -are often used for contextual help. - -You can redirect these `/help` links to either: - -- The more navigable and searchable version published at [`docs.gitlab.com`](https://docs.gitlab.com). -- A destination that meets [necessary requirements](#destination-requirements). +You can redirect all `/help` links to a destination that meets the [necessary requirements](#destination-requirements). 1. On the top bar, select **Main menu > Admin**. 1. On the left sidebar, select **Settings > Preferences**. @@ -86,17 +79,19 @@ You can redirect these `/help` links to either: 1. In the **Documentation pages URL** field, enter the URL. 1. Select **Save changes**. +If the "Documentation pages URL" field is empty, the GitLab instance displays a basic version of the documentation sourced from the [`doc` directory](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc) of GitLab. + ### Destination requirements When redirecting `/help`, GitLab: - Redirects requests to the specified URL. -- Appends `ee` and the documentation path to the URL. +- Appends `ee` and the documentation path, which includes the version number, to the URL. - Appends `.html` to the URL, and removes `.md` if necessary. For example, if the URL is set to `https://docs.gitlab.com`, requests for `/help/user/admin_area/settings/help_page.md` redirect to: -`https://docs.gitlab.com/ee/user/admin_area/settings/help_page.html`. +`https://docs.gitlab.com/${VERSION}/ee/user/admin_area/settings/help_page.html`. <!-- ## Troubleshooting diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 4da919d9ac6..2f6e4808c20 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -29896,6 +29896,9 @@ msgstr "" msgid "Notify|CI/CD project settings" msgstr "" +msgid "Notify|Check your forwarding settings and make sure the original email sender remains in the %{code_open}From%{code_end} header." +msgstr "" + msgid "Notify|Click here to set your password" msgstr "" @@ -29908,6 +29911,12 @@ msgstr "" msgid "Notify|Don't want to receive updates from GitLab administrators?" msgstr "" +msgid "Notify|Email could not be verified" +msgstr "" + +msgid "Notify|Email successfully verified" +msgstr "" + msgid "Notify|Error parsing CSV file. Please make sure it has the correct format: a delimited text file that uses a comma to separate values." msgstr "" @@ -29941,6 +29950,15 @@ msgstr "" msgid "Notify|If you no longer wish to use this domain with GitLab Pages, please remove it from your GitLab project and delete any related DNS records." msgstr "" +msgid "Notify|Incorrect %{code_open}From%{code_end} header:" +msgstr "" + +msgid "Notify|Incorrect verification token:" +msgstr "" + +msgid "Notify|Invalid credentials:" +msgstr "" + msgid "Notify|Issue was %{issue_status} by %{updated_by}" msgstr "" @@ -30004,6 +30022,9 @@ msgstr "" msgid "Notify|Pipeline has been fixed and #%{pipeline_id} has passed!" msgstr "" +msgid "Notify|Please check that your service provider supports email subaddressing and that you have set up email forwarding correctly." +msgstr "" + msgid "Notify|Please fix the lines with errors and try the CSV import again." msgstr "" @@ -30019,6 +30040,9 @@ msgstr "" msgid "Notify|Remote mirror" msgstr "" +msgid "Notify|SMTP host issue:" +msgstr "" + msgid "Notify|Some values in the \"type\" column could not be matched with supported work item types:" msgstr "" @@ -30040,6 +30064,9 @@ msgstr "" msgid "Notify|The errors we encountered were:" msgstr "" +msgid "Notify|The given credentials (username and password) were rejected by the SMTP server." +msgstr "" + msgid "Notify|The project is now located under %{project_full_name_link_start}%{project_full_name}%{link_end}." msgstr "" @@ -30055,15 +30082,42 @@ msgstr "" msgid "Notify|This link is valid for %{password_reset_token_valid_time}." msgstr "" +msgid "Notify|To enable the custom email address, go to your %{settings_link_start}project's Service Desk settings page%{settings_link_end}." +msgstr "" + +msgid "Notify|To restart the verification process, go to your %{settings_link_start}project's Service Desk settings page%{settings_link_end}." +msgstr "" + msgid "Notify|Unless you verify your domain by %{time_start}%{time}%{time_end} it will be removed from your GitLab project." msgstr "" +msgid "Notify|Verification email not received within timeframe:" +msgstr "" + msgid "Notify|Verification for custom email %{email} for %{project_name} triggered" msgstr "" +msgid "Notify|Verification result for custom email %{email} for %{project_name}" +msgstr "" + msgid "Notify|Verify custom email address %{email} for %{project_name}" msgstr "" +msgid "Notify|We could not verify that we received the email we sent to your email inbox." +msgstr "" + +msgid "Notify|We could not verify your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end}." +msgstr "" + +msgid "Notify|We did not receive the verification email we sent out to %{strong_open}%{email_address}%{strong_close} in time." +msgstr "" + +msgid "Notify|We wait for 30 minutes for messages to appear in your instance's Service Desk inbox." +msgstr "" + +msgid "Notify|We were not able to make a connection to the specified host or there was an SSL issue." +msgstr "" + msgid "Notify|You don't have access to the project." msgstr "" @@ -30082,6 +30136,9 @@ msgstr "" msgid "Notify|Your account has been created successfully." msgstr "" +msgid "Notify|Your email address %{strong_open}%{email_address}%{strong_close} for the Service Desk of %{project_link_start}%{project_name}%{project_link_end} was verified successfully." +msgstr "" + msgid "Notify|Your request to join the %{target_to_join} %{target_type} has been %{denied_tag}." msgstr "" diff --git a/spec/mailers/emails/service_desk_spec.rb b/spec/mailers/emails/service_desk_spec.rb index e76da38998b..76036fcd0b3 100644 --- a/spec/mailers/emails/service_desk_spec.rb +++ b/spec/mailers/emails/service_desk_spec.rb @@ -102,6 +102,19 @@ RSpec.describe Emails::ServiceDesk, feature_category: :service_desk do end end + shared_examples 'a custom email verification process result email with error' do |error_identifier, expected_text| + context "when having #{error_identifier} error" do + before do + service_desk_setting.custom_email_verification.error = error_identifier + end + + it 'contains correct error message headline in text part' do + # look for text part because we can ignore HTML tags then + expect(subject.text_part.body).to match(expected_text) + end + end + end + describe '.service_desk_thank_you_email' do let_it_be(:reply_in_subject) { true } let_it_be(:default_text) do @@ -364,4 +377,21 @@ RSpec.describe Emails::ServiceDesk, feature_category: :service_desk do is_expected.to have_body_text("@#{user.username}") end end + + describe '.service_desk_verification_result_email' do + before do + service_desk_setting.custom_email_verification.triggerer = user + end + + subject { Notify.service_desk_verification_result_email(service_desk_setting, 'owner@example.com') } + + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'a custom email verification process email' + it_behaves_like 'a custom email verification process notification email' + it_behaves_like 'a custom email verification process result email with error', 'smtp_host_issue', 'SMTP host issue' + it_behaves_like 'a custom email verification process result email with error', 'invalid_credentials', 'Invalid credentials' + it_behaves_like 'a custom email verification process result email with error', 'mail_not_received_within_timeframe', 'Verification email not received within timeframe' + it_behaves_like 'a custom email verification process result email with error', 'incorrect_from', 'Incorrect From header' + it_behaves_like 'a custom email verification process result email with error', 'incorrect_token', 'Incorrect verification token' + end end |