Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOFF-869 -Refactor notify component to enable email attachments #472

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

shamiluwais
Copy link
Contributor

@shamiluwais shamiluwais commented Aug 16, 2024

What
Refactor notify component to enable email attachments. HOFF-869

Why
The notify component in the hof framework is not enabled to send attachments with gov.notify emails, which is a requirement of the ROTM service, please HOFF-814.

How
Refactor the code to upload an attachment, without affecting other services that using the notify component to send emails.

Test
Test on two or more services using the hof notify component in local and branch

Screenshots(optional)

Anything else(optional)

Check list

  • I have reviewed my own pull request for linting issues (e.g. adding new lines)
  • I have written tests (if relevant)
  • I have created a JIRA number for my branch
  • I have created a JIRA number for my commit
  • I have followed the chris beams method for my commit https://cbea.ms/git-commit/, here is an example commit
  • Ensure drone builds are green especially tests
  • I will squash the commits before merging

Copy link
Contributor

@Rhodine-orleans-lindsay Rhodine-orleans-lindsay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good , just a couple of suggestions (see comments). Could you also please :

  • Add the jira ticket number in the commit?
  • Use the new pr description template for your pr description:

What

Why

How

Testing

Screenshots(optional)

Anything else(optional)

Check list

  • I have reviewed my own pull request for linting issues (e.g. adding new lines)
  • I have written tests (if relevant)
  • I have created a JIRA number for my branch
  • I have created a JIRA number for my commit
  • I have followed the chris beams method for my commit https://cbea.ms/git-commit/
    here is an example commit
  • Ensure drone builds are green especially tests
  • I will squash the commits before merging

personalisation: personalisation,
reference });
} catch (error) {
console.error('Error sending email:', error.response ? error.response.data : error.message);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we use hof's built in logger here? It provides more info when logging than console.error

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have refactored to use the hof logger component

Comment on lines 26 to 37
send(email) {
let personalisation = {
'email-subject': email.subject,
'email-body': email.body
};

if (email.attachment && email.attachment !== undefined) {
personalisation = Object.assign({'email-attachment':
this.notifyClient.prepareUpload(email.attachment)}, personalisation);
}

this.sendEmail(this.notifyTemplate, email.recipient, personalisation);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to make this function async as well and to use a try/catch block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed it to async

console.error('Error sending email:', error.response ? error.response.data : error.message);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also have a separate sendEmailWithAttachment function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did some investigation and it is will good but it is out of scope for this bit of work - Please raise it with the project team, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants