mailer: handle error at the caller instead
the send test email logic breaks if we disable throwing error in send
This commit is contained in:
@@ -47,6 +47,7 @@ const assert = require('assert'),
|
||||
debug = require('debug')('box:notifications'),
|
||||
eventlog = require('./eventlog.js'),
|
||||
mailer = require('./mailer.js'),
|
||||
safe = require('safetydance'),
|
||||
users = require('./users.js');
|
||||
|
||||
const NOTIFICATION_FIELDS = [ 'id', 'eventId', 'type', 'title', 'message', 'creationTime', 'acknowledged', 'context' ];
|
||||
@@ -167,7 +168,7 @@ async function oomEvent(eventId, containerId, app, addonName, event) {
|
||||
const admins = await users.getAdmins();
|
||||
for (const admin of admins) {
|
||||
if (admin.notificationConfig.includes(exports.TYPE_APP_OOM)) {
|
||||
await mailer.oomEvent(admin.email, containerId, app, addonName, event);
|
||||
await safe(mailer.oomEvent(admin.email, containerId, app, addonName, event), { debug });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +180,7 @@ async function appUp(eventId, app) {
|
||||
const admins = await users.getAdmins();
|
||||
for (const admin of admins) {
|
||||
if (admin.notificationConfig.includes(exports.TYPE_APP_UP)) {
|
||||
await mailer.appUp(admin.email, app);
|
||||
await safe(mailer.appUp(admin.email, app), { debug });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,7 +192,7 @@ async function appDown(eventId, app) {
|
||||
const admins = await users.getAdmins();
|
||||
for (const admin of admins) {
|
||||
if (admin.notificationConfig.includes(exports.TYPE_APP_DOWN)) {
|
||||
await mailer.appDown(admin.email, app);
|
||||
await safe(mailer.appDown(admin.email, app), { debug });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,7 +243,7 @@ async function boxUpdateError(eventId, errorMessage) {
|
||||
const admins = await users.getAdmins();
|
||||
for (const admin of admins) {
|
||||
if (admin.notificationConfig.includes(exports.TYPE_CLOUDRON_UPDATE_FAILED)) {
|
||||
await mailer.boxUpdateError(admin.email, errorMessage);
|
||||
await safe(mailer.boxUpdateError(admin.email, errorMessage), { debug });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -257,7 +258,7 @@ async function certificateRenewalError(eventId, fqdn, errorMessage) {
|
||||
const admins = await users.getAdmins();
|
||||
for (const admin of admins) {
|
||||
if (admin.notificationConfig.includes(exports.TYPE_CERTIFICATE_RENEWAL_FAILED)) {
|
||||
await mailer.certificateRenewalError(admin.email, fqdn, errorMessage);
|
||||
await safe(mailer.certificateRenewalError(admin.email, fqdn, errorMessage), { debug });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -273,7 +274,7 @@ async function backupFailed(eventId, taskId, errorMessage) {
|
||||
const superadmins = await users.getSuperadmins();
|
||||
for (const superadmin of superadmins) {
|
||||
if (superadmin.notificationConfig.includes(exports.TYPE_BACKUP_FAILED)) {
|
||||
await mailer.backupFailed(superadmin.email, errorMessage, `https://${dashboardFqdn}/logs.html?taskId=${taskId}`);
|
||||
await safe(mailer.backupFailed(superadmin.email, errorMessage, `https://${dashboardFqdn}/logs.html?taskId=${taskId}`), { debug });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,7 +283,7 @@ async function rebootRequired() {
|
||||
const admins = await users.getAdmins();
|
||||
for (const admin of admins) {
|
||||
if (admin.notificationConfig.includes(exports.TYPE_REBOOT)) {
|
||||
await mailer.rebootRequired(admin.email);
|
||||
await safe(mailer.rebootRequired(admin.email), { debug });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -293,7 +294,7 @@ async function lowDiskSpace(message) {
|
||||
const admins = await users.getAdmins();
|
||||
for (const admin of admins) {
|
||||
if (admin.notificationConfig.includes(exports.TYPE_DISK_SPACE)) {
|
||||
await mailer.lowDiskSpace(admin.email, message);
|
||||
await safe(mailer.lowDiskSpace(admin.email, message), { debug });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user