Native attachments for Service Desk emails
Summary
When emails are sent from the Service Desk, images which are attached to the issue can be downloaded but files cannot be downloaded unless the user has a login to the Service Desk. Before a recent change (11.11 https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28305), a file attached to an issue could be downloaded by any recipient of a service desk email.
Steps to reproduce
- Enable Service Desk
- Send an email to the service desk
- Comment on the service desk issue and include an image and a file (e.g. a PDF)
- Receive the email -- the image will be displayed and the file will be presented as a link.
- Copying the link to a web browser which is not logged into Gitlab asks the user to login.
Example Project
It happens on all our internal projects. As an example this link
https://gitlab.com/widearea/inframation-news/uploads/e458e4bb8728e337d91a660863578700/image.png
works but this one does not
What is the current bug behavior?
The recipient of the Service Desk email cannot download files attached to emails. (Recent behaviour change)
What is the expected correct behavior?
The recipient of the Service Desk email can download files attached to emails. (Original behaviour)
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
n/a
Results of GitLab application Check
n/a
Possible solution
- Implement a new route that proxies to the attachment via a stored record, without authentication.
- Detect attachment being uploaded to or linked in a Service Desk issue comment and create a record for that attachment.
- Replace the link to the attachment with the new route in the outgoing email to the customer.
- Add native attachments for Service Desk new note emails (preferred variant right now). See this and the following comments and also above comments for context
Possible implementation path
For context see full comment.
- The NewNoteWorker triggers note notifications and service_desk_new_note_email renders the email.
- I did not find any convenient method to get the uploads to a note. Uploads can be accessed by the
Upload
model and thesecret
that is part of the upload url. E.g. you may have a note text like this:"<p data-sourcepos=\"1:1-1:118\" dir=\"auto\"><a href=\"/uploads/39b53d205631ccbc5fb589a69505e85e/JTBD_Interview_Notes_-_Template.xlsx\">JTBD_Interview_Notes_-_Template.xlsx</a></p>"
. You can get the note withu = Upload.find_by(secret: "39b53d205631ccbc5fb589a69505e85e")
. - I did a quick check: I was able to read the file content via
File.read(u.absolute_path)
. Maybe you should ask a backend engineer from the plan stage how you should access the uploads properly. - In NotificationService#
send_service_desk_notification
we walk through all email recipients (which should be 0 or 1 right now, but will be more in the future), so we should collect the uploads that need to be attached before that, so we do not need to refetch the files from the remote storage for each recipient. - I think you should be able to add attachments to ActionMailer in the mailer method by adding something like
attachments['filename.ext'] = File.read(filepath)
- We should then remove the upload html from the
Note#note_html
for the Service Desk notification email. - The frontend should check for the overall size of uploads attached to a new note and render some kind of warning that the email might not get through because it's too large. IMHO it could be some alert html near the editor or a simple browser dialog. I think for the first iteration we should focus on making this work. We can improve on the warning side later on.
Release notes
Description: Customer support agents often send screenshots and smaller files to Service Desk issue authors. If your GitLab instance is not reachable from the internet or you use a private group that requires authentication to access issue uploads, issue authors won't be able to access the assets.
GitLab now sends uploads in comments to Service Desk issues as native email attachments (for attachment sizes below 10MB). This way issue authors will always have access to the assets and can archive them in their email mailbox.
Documentation: https://docs.gitlab.com/ee/user/project/service_desk.html#receiving-files-attached-to-comments-as-email-attachments