Adds custom email create and destroy service
Feature context
Click to expand 👇
Right now it is not possible to customize the Service Desk email address (intake and sending) in its entirety. On self-hosted instances you have more control over the used addresses, but you will still have a rather cryptic target email address for a specific service desk in a project. For .com users it's currently not possible to customize the Service Desk email at all.
There is a proposal and a further exploration around this issue. A summary of the solution path is the following: Users set up their custom email to forward all emails to the cryptic Service Desk email and provide SMTP credentials so we can send emails on their behalf. This way customers seeking support will only see the custom email address in their communication.
There is further discussion about improving and changing the general infrastructure, but this approach is a MVC to solve the issue for our customers.
🗺 How does it contribute to the whole feature?
This MR is part of a series of MRs that will follow in order to complete this feature. See #329990 (comment 1227384943) for a detailed breakdown. Here's a summary:
-
✅ Using SMTP credentials. Foundation work. Add Service Desk custom email foundation (!108017 - merged) -
✅ Verify email ownership, correct function and setup -
🎯 Add settings and validation to Settings page. Part 1: Controller services for endpoint - Ingest replies from custom email
- Add documentation
What does this MR do and why?
This MR introduces two new services that pieces the previous work on custom email addresses together.
- The
CreateService
will be called from a controller action that will be triggered from a vue app on the Service Desk settings page. The service will then update theServiceDeskSetting
with the givencustom_email
, add the given credentials to aCustomEmailCredential
record and trigger the verification process. - The
DestroyService
will also be called from a controller action (also triggered via vue app). Apart from enabling or disabling the custom email address (after verification) there won't be a way to edit the custom email records. The only way to change the configuration is to delete the custom email address and it's records and start the process again. This service makes sure all records get deleted. Adds custom email create and destroy service - I also touched
ServiceDeskSetting::UpdateService
because it didn't returnServiceResponse
yet and it did not feel right to use a legacy result in this new service. Only minor changes to the calling controller and spec file.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
How to set up and validate locally
-
Select a project that you didn't use for Service Desk custom email testing purposes before. Id
6
worked fine for me -
Get objects and enable feature flag for project
project = Project.find 6 user = User.first Feature.enable(:service_desk_custom_email, project)
-
Trigger service with params (note,
smtp_address
must be resolvable, I use gmail for this)params = { custom_email: 'doesntexist@gmail.com', smtp_address: 'smtp.gmail.com', smtp_port: '587', smtp_username: 'doesntexist@gmail.com', smtp_password: 'supersecret' } response = ServiceDesk::CustomEmails::CreateService.new( project: project, current_user: user, params: params ).execute
-
Reset project and check response and records (because these are not valid credentials, the verification record will eventually move to the
failed
state. But that's fine here. If you provide correct credentials it should be instarted
state).project.reset pp response pp project.service_desk_setting pp project.service_desk_custom_email_credential pp project.service_desk_custom_email_verification
-
Now delete everything again
response = ServiceDesk::CustomEmails::DestroyService.new( project: project, current_user: user ).execute
-
Reuse code from 4. to check the response and that we deleted everything.
-
You can also disable the feature flag and see the service error plus message
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.