Service Desk: Always display custom email display name
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
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.
master
branch.
On - 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.
- In a project, go to Settings -> General -> Service Desk. Toggle Service Desk to enable it.
- The settings should look like this - no "email display name" text box.
- Switch to this branch.
On this branch
- Reload the page and you should see the text box
👍 Set it to some value and save.
- 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
- Open letter-opener at https://gdk.test:3443/rails/letter_opener/ and
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #368737 (closed)