Skip to content

Automatically add CC as issue email participants

Marc Saleiko requested to merge ms-add-cc-issue-email-participants into master

What does this MR do and why?

Contributes to Service Desk should add emails in the To line a... (#4652 - closed)

This feature is hidden behind the feature flag 🎏 issue_email_participants.

When a received Service Desk email contains CC addresses they are now also added as external issue email participants if the settings flag add_external_participants_from_cc in ServiceDeskSetting is checked.

The add_external_participants_from_cc database field was introduced in Adds add_external_participants_from_cc to Servi... (!133859 - merged) • Marc Saleiko • 16.5. The frontend part on the project settings page will follow shortly.

Screenshots or screen recordings

🚫 backend only

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Select a project and enable the feature flag for issue_email_participants.
    project = Project.find(7)
    
    Feature.enable(:issue_email_participants, project)
  2. Ingest a sample eamail with a CC field.
    service_desk_address = project.service_desk_incoming_address
    
    email_raw = <<~EMAIL
    To: #{service_desk_address}
    From: user@example.com
    Cc: cc@example.com
    Subject: CC SD issue
    
    This issue should have the author and cc as external participants.
    EMAIL
    
    EmailReceiverWorker.new.perform(email_raw)
  3. Because the add_external_participants_from_cc flag in ServiceDeskSetting is false by default this should add an issue with only one external participant (the author).
    issue = Issue.last
    puts issue.title
    puts issue.issue_email_participants.pluck(:email).join(', ')
  4. Now enable the setting
    ServiceDeskSettings::UpdateService.new(project, User.first, add_external_participants_from_cc: true).execute
  5. Repeat steps 2) and 3). This time you should see two external participants.
  6. You can also check for more than one CC with the email snippet from below and repeating steps 2) and 3).
    email_raw = <<~EMAIL
    To: #{service_desk_address}
    From: user@example.com
    Cc: cc@example.com, dd@example.com
    Subject: CC SD issue
    
    This issue should have the author and cc as external participants.
    EMAIL
  7. (Optional) Use this to rollback the changes to your project
    ServiceDeskSettings::UpdateService.new(project, User.first, add_external_participants_from_cc: false).execute
    Feature.disable(:issue_email_participants, project)

MR acceptance checklist

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

Edited by Marc Saleiko

Merge request reports