Skip to content

Service Desk: Always display custom email display name

charlie ablett requested to merge 368737-cablett-service-desk-email-display into master

What does this MR do and why?

When trying to use a custom email display name for Service Desk, there is no textbox in the UI on Settings 👉 General 👉 Service Desk.

In c9a40be0 a condition was added to this input that only appears when custom Service Desk inbox is configured.

This MR removes that condition and adds some specs.

How to set up and validate locally

Follow https://docs.gitlab.com/ee/administration/incoming_email.html to enable incoming email and https://docs.gitlab.com/ee/user/project/service_desk.html to set up Service Desk.

On master branch.

  1. In your GitLab instance, ensure the following yml settings:
incoming_email:
  enabled: true
  # we don't care about the other settings

service_desk_email:
  enabled: false
  # we don't care about the other settings

and restart your instance if they have changed.

  1. In a project, go to Settings -> General -> Service Desk. Toggle Service Desk to enable it.
  2. The settings should look like this - no "email display name" text box.

image

  1. Switch to this branch.

On this branch

  1. Reload the page and you should see the text box 👍 Set it to some value and save.

image

  1. Send an email to your Service Desk address under the project/ If it doesn't work, you can spoof it like so:

make the following code change:

diff --git a/lib/gitlab/email/handler/service_desk_handler.rb b/lib/gitlab/email/handler/service_desk_handler.rb
index 06365296a76f..ee63d05da975 100644
--- a/lib/gitlab/email/handler/service_desk_handler.rb
+++ b/lib/gitlab/email/handler/service_desk_handler.rb
@@ -60,9 +60,7 @@ def metrics_event
 
         def project
           strong_memoize(:project) do
-            project_record = super
-            project_record ||= project_from_key if service_desk_key
-            project_record&.service_desk_enabled? ? project_record : nil
+            Project.find(6) # or whatever the project ID is
           end
         end

and run the following in console:

[1] pry(main)> raw = <<-RAW
Date: Fri, 11 Nov 2022 17:03:48 +1300
From: Lost User <lostuser@example.com>
To: can-be-any-email-because-its-being-spoofed@example.com
Subject: Oh noes!

Talk to me, Super Service Desk Ultra Bot Thing!
RAW
=> "Date: Fri, 11 Nov 2022 17:03:48 +1300\nFrom: Lost User <lostuser@example.com>\nTo: contact_project+group-project-20-issue-@gmail.com\nSubject: Oh noes!\n\nTalk to me, Super Service Desk Ultra Bot Thing!\n"
[2] pry(main)> Gitlab::Email::ServiceDeskReceiver.new(raw).execute
  1. Open letter-opener at https://gdk.test:3443/rails/letter_opener/ and

image

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #368737 (closed)

Edited by charlie ablett

Merge request reports