-
Notifications
You must be signed in to change notification settings - Fork 0
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
Spike Batch Notify #1749
base: main
Are you sure you want to change the base?
Spike Batch Notify #1749
Conversation
https://eaflood.atlassian.net/browse/WATER-4904 Get the batch notifications working and dive out the design / structure of the code.
async function _sendLetter(recipient) { | ||
const data = _formatLetter(recipient) | ||
|
||
return NotifyLetterService.go(data.templateId, data.options).then((res) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems necessary to allow the Notify functions to be a simple notify response and not worry about returning the personalisation and contact hash to the caller.
We need the contact hash if there is an error to retry the notify calls - will need to this in the catch. ?
* @param returnsPeriod | ||
* @param referenceCode | ||
*/ | ||
function go(recipient, returnsPeriod, referenceCode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
presenters make sense to format the data for the notify calls.
The question would be should we do it before each request is made. Or format all the recipients into notifications.
I am leaning to changing all in the recipients in the array into a something like notifications. As we have a clear delineation between a recipient and a notification.
As we are using the existing DB table with a personalisation column this make sense.
} | ||
|
||
async function _sendEmail(recipient, returnsPeriod, referenceCode) { | ||
const formatedData = NotifyEmailPresenter.go(recipient, returnsPeriod, referenceCode) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this to the array prior to this should allow us to handle the errors / success simpler in the batch.
If we can remove the need to use the contact hash then i think this is better.
We get all the results resolved promises and we can handle the errors and resend the 'payload'
const failed = notifications.filter((response) => response.status !== 'fulfilled')
https://eaflood.atlassian.net/browse/WATER-4904
Get the batch notifications working and dive out the design / structure of the code.