From 1aa42aa0e837ab5f1621afb7cabe7b070908767d Mon Sep 17 00:00:00 2001 From: cgeek Date: Tue, 11 Jun 2019 13:35:45 +0200 Subject: [PATCH] [enh] hostname in mails --- src/lib/mail.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/lib/mail.ts b/src/lib/mail.ts index 6d9c697..e66d2ca 100644 --- a/src/lib/mail.ts +++ b/src/lib/mail.ts @@ -2,6 +2,7 @@ import {moment} from "duniter/app/lib/common-libs/moment"; import {Conf} from "./types/conf"; import {ConfMail} from './types/conf' import * as nodemailer from 'nodemailer' +import * as os from 'os' export async function sendMail(conf: ConfMail, subject: string, html: string) { @@ -33,7 +34,7 @@ export const mail = { onEstablished: (conf: Conf, target: string) => { return async () => { console.log('Connection established') - await sendMail(conf.mail, '[dwatcher] Connection established', ` + await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection established`, `

Connection to ${target} established on ${moment().format('DD-MM-YYYY HH:mm:ss')}.

@@ -45,7 +46,7 @@ export const mail = { return async (waitingDelay: number) => { console.log('Connection closed') console.log('Waiting %s seconds...', waitingDelay) - await sendMail(conf.mail, '[dwatcher] Connection closed', ` + await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection closed`, `

Connection to ${target} was lost on ${moment().format('dd-MM-YYYY HH:mm:ss')}.

@@ -59,7 +60,7 @@ export const mail = { onRestartSuccess: (conf: Conf, target: string) => { return async () => { console.log('Connection recovered') - await sendMail(conf.mail, '[dwatcher] Connection recovered', ` + await sendMail(conf.mail, `[dwatcher] [${os.hostname}] Connection recovered`, `

Connection to ${target} was recovered on ${moment().format('dd-MM-YYYY HH:mm:ss')}.

@@ -70,7 +71,7 @@ export const mail = { onError: (conf: Conf, target: string) => { return async (e: Error) => { console.error(e.message || e) - // await sendMail(conf.mail, '[dwatcher] Connection error', ` + // await sendMail(conf.mail, `[dwatcher] Connection error`, ` //

// Connection error with ${target} on ${moment().format('dd-MM-YYYY HH:mm:ss')}: //