From d6b5363ab9387f62663f8d3e9a9c01ed080b22db Mon Sep 17 00:00:00 2001 From: Nicholas Wallace Date: Sat, 3 Aug 2024 14:52:49 -0700 Subject: [PATCH] Add: failed backup notification --- server/managers/NotificationManager.js | 10 ++++++++++ server/utils/notifications.js | 13 +++++++++++++ 2 files changed, 23 insertions(+) diff --git a/server/managers/NotificationManager.js b/server/managers/NotificationManager.js index ec723db91..2800ac967 100644 --- a/server/managers/NotificationManager.js +++ b/server/managers/NotificationManager.js @@ -50,6 +50,16 @@ class NotificationManager { this.triggerNotification('onBackupCompleted', eventData) } + async onBackupFailed(errorMsg) { + if (!Database.notificationSettings.isUseable) return + + Logger.debug(`[NotificationManager] onBackupFailed: Backup failed`) + const eventData = { + errorMsg: errorMsg || 'Backup failed' + } + this.triggerNotification('onBackupFailed', eventData) + } + onTest() { this.triggerNotification('onTest') } diff --git a/server/utils/notifications.js b/server/utils/notifications.js index 00d88c0d8..96e8ddf8c 100644 --- a/server/utils/notifications.js +++ b/server/utils/notifications.js @@ -44,6 +44,19 @@ module.exports.notificationData = { removedOldest: 'false' } }, + { + name: 'onBackupFailed', + requiresLibrary: false, + description: 'Triggered when a backup fails', + variables: ['errorMsg'], + defaults: { + title: 'Backup Failed', + body: 'Backup failed, check ABS logs for more information.\nError message: {{errorMsg}}' + }, + testData: { + errorMsg: 'Example error message' + } + }, { name: 'onTest', requiresLibrary: false,