Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from: notificationDefaultParams.MAIL_FROM,
headers: {
"X-Italia-Messages-MessageId": message.id,
"X-Italia-Messages-NotificationId": notificationId
},
html: documentHtml,
messageId: message.id,
subject: content.subject,
text: bodyText,
to: emailNotification.toAddress
// priority: "high", // TODO: set based on kind of notification
// disableFileAccess: true,
// disableUrlAccess: true,
});
const sendMailCallDurationMs = diffInMilliseconds(startSendMailCallTime);
const eventName = "notification.email.delivery";
const eventContent = {
dependencyTypeName: "HTTP",
duration: sendMailCallDurationMs,
name: eventName,
properties: {
addressSource: emailNotification.addressSource,
transport: lMailerTransporter.transporter.name
}
};
if (isLeft(sendResult)) {
const error = sendResult.value;
// track the event of failed delivery
)
);
}
const webhookNotification = errorOrWebhookNotification.value.channels.WEBHOOK;
const startWebhookCallTime = process.hrtime();
const sendResult = await sendToWebhook(
webhookNotification.url,
message,
content,
senderMetadata
);
const webhookCallDurationMs = diffInMilliseconds(startWebhookCallTime);
const eventName = "notification.webhook.delivery";
// hide backend secret token in logs
const hostName = UrlFromString.decode(webhookNotification.url).fold(
_ => "invalid url",
url => url.hostname || "invalid hostname"
);
const eventContent = {
data: hostName,
dependencyTypeName: "HTTP",
duration: webhookCallDurationMs,
name: eventName
};
);
}
// queue the message to the created messages queue by setting
// the message to the output binding of this function
// tslint:disable-next-line:no-object-mutation
context.bindings.createdMessage = createdMessageEventOrError.value;
//
// generate appinsights event
//
// track the event that a message has been created
appInsightsClient.trackEvent({
measurements: {
duration: diffInMilliseconds(startRequestTime)
},
name: appInsightsEventName,
properties: {
...appInsightsEventProps,
success: "true"
}
});
//
// respond to request
//
// redirect the client to the message resource
return ResponseSuccessRedirectToResource(
newMessageWithoutContent,
`/api/v1/messages/${fiscalCode}/${newMessageWithoutContent.id}`,