From 6f32a9eb3bd3998446f744b63babc5fadeb3a405 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Sat, 6 Aug 2022 19:14:20 +0200 Subject: [PATCH] Send status e-mail --- lib/processoutage.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/processoutage.js b/lib/processoutage.js index 1e5b05b..b51df9f 100644 --- a/lib/processoutage.js +++ b/lib/processoutage.js @@ -56,16 +56,26 @@ async function processOutage({ outage, server, settings, onDateUpdated }) { // Send e-mail notification if (server.sendEmail && settings.emailSender && settings.emailRecipient) { try { - server.sendEmail({ + const date = new Date().toLocaleString('en-GB', { + dateStyle: 'full', + timeStyle: 'full', + timeZone: 'Etc/UTC', + }); + const a = await server.sendEmail({ sender: settings.emailSender, to: settings.emailRecipient, subject: `[outage] ${service.name} is down`, - body: `

Dear recipient,

-

This is to inform you about web service outage. - The service ${service.name} does not meet the - requirements for being considered as 'working'.

-

Please always check this before taking action.

`, + body: `Dear recipient, + +As of ${date} UTC time, the service "${service.name}" does not meet the requirements for being +considered as working. + +Technical information containing the reason for this alert: +${JSON.stringify(testResult, null, 2)} + +Please always check this before taking action. This is an automated message.`, }); + console.log(a); } catch (err) { server.error('could not send endpoint status notification e-mail');