diff --git a/assets/src/bundles/add_forge/add-request-history-item.ejs b/assets/src/bundles/add_forge/add-request-history-item.ejs --- a/assets/src/bundles/add_forge/add-request-history-item.ejs +++ b/assets/src/bundles/add_forge/add-request-history-item.ejs @@ -6,9 +6,9 @@ %>
<%= event.text %>
+<%= event.text %><%if (event.message_source_url !== null) { %>
Open original message in email client
<% } %> diff --git a/assets/src/bundles/add_forge/request-dashboard.js b/assets/src/bundles/add_forge/request-dashboard.js --- a/assets/src/bundles/add_forge/request-dashboard.js +++ b/assets/src/bundles/add_forge/request-dashboard.js @@ -57,13 +57,19 @@ // Setting data for the email, now adding static data $('#contactForgeAdmin').attr('emailTo', forgeRequest.forge_contact_email); + $('#contactForgeAdmin').attr('emailCc', forgeRequest.inbound_email_address); $('#contactForgeAdmin').attr('emailSubject', `Software Heritage archival request for ${forgeRequest.forge_domain}`); populateRequestHistory(data.history); populateDecisionSelectOption(forgeRequest.status); - } catch (response) { - // The error message - $('#fetchError').removeClass('d-none'); - $('#requestDetails').addClass('d-none'); + } catch (e) { + if (e instanceof Response) { + // The fetch request failed (in handleFetchError), show the error message + $('#fetchError').removeClass('d-none'); + $('#requestDetails').addClass('d-none'); + } else { + // Unknown exception, pass it through + throw e; + } } } @@ -123,9 +129,10 @@ function contactForgeAdmin(event) { // Open the mailclient with pre-filled text const mailTo = $('#contactForgeAdmin').attr('emailTo'); + const mailCc = $('#contactForgeAdmin').attr('emailCc'); const subject = $('#contactForgeAdmin').attr('emailSubject'); const emailText = emailTempate({'forgeUrl': forgeRequest.forge_url}).trim().replace(/\n/g, '%0D%0A'); const w = window.open('', '_blank', '', true); - w.location.href = `mailto: ${mailTo}?subject=${subject}&body=${emailText}`; + w.location.href = `mailto:${mailTo}?Cc=${mailCc}&Reply-To=${mailCc}&Subject=${subject}&body=${emailText}`; w.focus(); } diff --git a/cypress/integration/add-forge-now-request-dashboard.spec.js b/cypress/integration/add-forge-now-request-dashboard.spec.js --- a/cypress/integration/add-forge-now-request-dashboard.spec.js +++ b/cypress/integration/add-forge-now-request-dashboard.spec.js @@ -5,31 +5,36 @@ * See top-level LICENSE file for more information */ -let requestId, forgeDomain; +let requestId; +let requestForgeDomain; +let requestInboundEmailAddress; + +const requestData = { + forge_type: 'bitbucket', + forge_url: 'test.example.com', + forge_contact_email: 'test@example.com', + forge_contact_name: 'test user', + submitter_forward_username: true, + forge_contact_comment: 'test comment' +}; function createDummyRequest(urls) { cy.task('db:add_forge_now:delete'); cy.userLogin(); - cy.getCookie('csrftoken').its('value').then((token) => { + return cy.getCookie('csrftoken').its('value').then((token) => { cy.request({ method: 'POST', url: urls.api_1_add_forge_request_create(), - body: { - forge_type: 'bitbucket', - forge_url: 'test.example.com', - forge_contact_email: 'test@example.com', - forge_contact_name: 'test user', - submitter_forward_username: true, - forge_contact_comment: 'test comment' - }, + body: requestData, headers: { 'X-CSRFToken': token } }).then((response) => { // setting requestId and forgeDomain from response requestId = response.body.id; - forgeDomain = response.body.forge_domain; + requestForgeDomain = response.body.forge_domain; + requestInboundEmailAddress = response.body.inbound_email_address; // logout the user cy.visit(urls.swh_web_homepage()); cy.contains('a', 'logout').click(); @@ -37,6 +42,46 @@ }); } +function genEmailSrc() { + return `Message-ID: