{"size": 1771, "ext": "js", "max_stars_repo_path": "src/utils/emailTemplates/buildPipelineStatusEmailBody.js", "max_stars_repo_name": "biomage-ltd/api", "max_stars_repo_stars_event_min_datetime": "2020-11-12T12:21:15.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-19T10:09:08.000Z", "max_issues_repo_path": "src/utils/emailTemplates/buildPipelineStatusEmailBody.js", "max_issues_repo_name": "biomage-ltd/api", "max_issues_repo_issues_event_min_datetime": "2020-09-15T14:07:58.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-05T14:13:28.000Z", "max_forks_repo_path": "src/utils/emailTemplates/buildPipelineStatusEmailBody.js", "max_forks_repo_name": "biomage-ltd/api", "max_forks_repo_forks_event_min_datetime": "2020-11-11T10:11:04.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-14T19:22:58.000Z"}
{"max_stars_count": 15, "max_issues_count": 129, "max_forks_count": 3, "avg_line_length": 31.0701754386, "max_line_length": 132, "alphanum_fraction": 0.5736871824}
const {
  SUCCEEDED,
} = require('../../api/general-services/pipeline-manage/constants');

const buildPipelineStatusEmailBody = (experimentId, status, user) => {
  const firstname = user.name.split(' ')[0];
  const link = `scp.biomage.net/experiments/${experimentId}/data-processing`;
  const successMessage = `
      The data processing pipeline has completed successfully and your data is now ready to explore:<br/>
      <a href="${link}">${link}</a>
      Happy analysing! <br/>`;
  const failMessage = `
      Unfortunately, when trying to run the analysis the data processing failed for your experiment: <br/>
      <a href="${link}">${link}</a> <br/>
      We are working hard to identify and fix the issue. We will let you know as soon as your data is ready to explore. <br/>
      `;
  const messageToSend = `
        <html>
        <head>
        </head>
        <body>
            <h3>Hello ${firstname},</h3>
            <p>Thanks for using Cellenics! <br/>
              ${status === SUCCEEDED ? successMessage : failMessage}<br/><br/>
                The Biomage Team 
              <small> <br/> <br/> You can disable the notifications for this experiment when you start processing it again. </small>
            <p/>
        </body>
      </html>`;


  const params = {
    Destination: {
      ToAddresses: [user.email],
    },
    Message: {
      Body: {
        Text: {
          Charset: 'UTF-8',
          Data: messageToSend,
        },
        Html: {
          Charset: 'UTF-8',
          Data: messageToSend,
        },
      },
      Subject: {
        Charset: 'UTF-8',
        Data: 'Cellenics experiment status',
      },
    },
    Source: 'notification@biomage.net',
  };
  return params;
};
module.exports = buildPipelineStatusEmailBody;
