make notifications.alert take a title

the title is better when it's a bit more dynamic
This commit is contained in:
Girish Ramakrishnan
2019-03-07 14:49:38 -08:00
parent 4428c3d7d8
commit 66b02b58b6
3 changed files with 8 additions and 19 deletions
+2 -13
View File
@@ -36,15 +36,6 @@ let assert = require('assert'),
users = require('./users.js'),
util = require('util');
// These titles are matched for upsert
const ALERT_TITLES = {
backupConfig: 'Backup configuration is unsafe',
diskSpace: 'Out of Disk Space',
mailStatus: 'Email is not configured properly',
reboot: 'Reboot Required',
boxUpdate: 'New Cloudron Version Available'
};
function NotificationsError(reason, errorOrMessage) {
assert.strictEqual(typeof reason, 'string');
assert(errorOrMessage instanceof Error || typeof errorOrMessage === 'string' || typeof errorOrMessage === 'undefined');
@@ -335,14 +326,12 @@ function upsert(userId, eventId, title, message, callback) {
});
}
function alert(id, message, callback) {
function alert(id, title, message, callback) {
assert.strictEqual(typeof id, 'string');
assert.strictEqual(typeof title, 'string');
assert.strictEqual(typeof message, 'string');
assert.strictEqual(typeof callback, 'function');
const title = ALERT_TITLES[id];
if (!title) return callback();
debug(`alert: id=${id} title=${title} message=${message}`);
actionForAllAdmins([], function (admin, callback) {