Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
response => {
if (response.error) {
return left(
// in case of server HTTP 5xx errors we trigger a retry
response.serverError
? TransientError(
`Transient HTTP error calling API Proxy: ${response.text}`
)
: PermanentError(
`Permanent HTTP error calling API Proxy: ${response.text}`
)
);
}
return right(response);
},
err => {
TransientError(
`Notification not found|notification=${notificationId}|message=${
message.id
}`
)
);
}
const errorOrEmailNotification = EmailNotification.decode(
maybeEmailNotification.value
);
if (isLeft(errorOrEmailNotification)) {
const error = readableReport(errorOrEmailNotification.value);
return left(
PermanentError(
`Wrong format for email notification|notification=${notificationId}|message=${
message.id
}|${error}`
)
);
}
const emailNotification = errorOrEmailNotification.value.channels.EMAIL;
const documentHtml = await generateDocumentHtml(
content.subject,
content.markdown,
senderMetadata
);
// converts the HTML to pure text to generate the text version of the message
TransientError(
`Notification not found|notification=${notificationId}|message=${
message.id
}`
)
);
}
const errorOrWebhookNotification = WebhookNotification.decode(
maybeWebhookNotification.value
);
if (isLeft(errorOrWebhookNotification)) {
const error = readableReport(errorOrWebhookNotification.value);
return left(
PermanentError(
`Wrong format for webhook notification|notification=${notificationId}|message=${
message.id
}|${error}`
)
);
}
const webhookNotification = errorOrWebhookNotification.value.channels.WEBHOOK;
const startWebhookCallTime = process.hrtime();
const sendResult = await sendToWebhook(
webhookNotification.url,
message,
content,
senderMetadata