Skip to content

A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.

fix: resolves unnecessary logging

towfiqie6806cb03fc2
diff --git a/backend/__tests__/notifications/BackupNotification.test.ts b/backend/__tests__/notifications/BackupNotification.test.ts
index d72385d..15c91c1 100644
--- a/backend/__tests__/notifications/BackupNotification.test.ts
+++ b/backend/__tests__/notifications/BackupNotification.test.ts
@@ -240,9 +240,8 @@ describe('BackupNotification', () => {
await backupNotification.sendEmail(mockPlan, 'start', { id: 'backup-1' });
expect(mockChannel.send).not.toHaveBeenCalled();
- expect(mockLogger.error).toHaveBeenCalledWith(
- expect.stringContaining('Does not match Plan Notification Case')
- );
+ expect(mockLogger.error).not.toHaveBeenCalled();
+ expect(mockLogger.info).not.toHaveBeenCalled();
});
it('should throw error when emails are missing', async () => {
@@ -318,9 +317,8 @@ describe('BackupNotification', () => {
await backupNotification.sendSlack(mockPlan, 'start', { id: 'backup-1' });
expect(mockSlackChannel.send).not.toHaveBeenCalled();
- expect(mockLogger.error).toHaveBeenCalledWith(
- expect.stringContaining('Does not match Plan Notification Case')
- );
+ expect(mockLogger.error).not.toHaveBeenCalled();
+ expect(mockLogger.info).not.toHaveBeenCalled();
});
it('should throw error when webhook URL is missing', async () => {
@@ -403,9 +401,8 @@ describe('BackupNotification', () => {
await backupNotification.sendDiscord(mockPlan, 'start', { id: 'backup-1' });
expect(mockDiscordChannel.send).not.toHaveBeenCalled();
- expect(mockLogger.error).toHaveBeenCalledWith(
- expect.stringContaining('Does not match Plan Notification Case')
- );
+ expect(mockLogger.error).not.toHaveBeenCalled();
+ expect(mockLogger.info).not.toHaveBeenCalled();
});
it('should throw error when webhook URL is missing', async () => {
diff --git a/backend/src/notifications/BackupNotification.ts b/backend/src/notifications/BackupNotification.ts
index 176ad27..5cb31cb 100644
--- a/backend/src/notifications/BackupNotification.ts
+++ b/backend/src/notifications/BackupNotification.ts
@@ -63,7 +63,7 @@ export class BackupNotification {
try {
const notification = plan.settings.notification;
const shouldSend = this.shouldSend(notification?.email?.case || 'end', notificationType);
- if (!shouldSend) throw new Error('Does not match Plan Notification Case.');
+ if (!shouldSend) return;
const emailType = notification?.email?.type || 'smtp';
if (!notification?.email?.emails) throw new Error('Email Notification Emails Missing.');
@@ -103,8 +103,7 @@ export class BackupNotification {
const notification = plan.settings.notification;
const theCase = notificationCase ? notificationCase : notification?.slack?.case || 'end';
const shouldSend = notificationCase ? true : this.shouldSend(theCase, notificationType);
-
- if (!shouldSend) throw new Error('Does not match Plan Notification Case.');
+ if (!shouldSend) return;
const webhookUrl = notification?.slack?.url;
if (!webhookUrl) throw new Error('Slack Webhook URL Missing.');
@@ -142,7 +141,7 @@ export class BackupNotification {
const notification = plan.settings.notification;
const theCase = notificationCase ? notificationCase : notification?.discord?.case || 'end';
const shouldSend = notificationCase ? true : this.shouldSend(theCase, notificationType);
- if (!shouldSend) throw new Error('Does not match Plan Notification Case.');
+ if (!shouldSend) return;
const webhookUrl = notification?.discord?.url;
if (!webhookUrl) throw new Error('Discord Webhook URL Missing.');
@@ -180,7 +179,7 @@ export class BackupNotification {
const { notification } = plan.settings;
const theCase = notificationCase ? notificationCase : notification?.push?.case || 'end';
const shouldSend = notificationCase ? true : this.shouldSend(theCase, notificationType);
- if (!shouldSend) throw new Error('Does not match Plan Notification Case.');
+ if (!shouldSend) return;
if (!notification?.push?.url) throw new Error('Push Notification URL missing.');
const ntfyChannel = await this.notificationChannelResolver.getChannel('ntfy');