A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
feat: adds discord and slack notification methods
towfiqibdbf85dbb479
diff --git a/backend/__tests__/notifications/BackupFailedNotification.test.ts b/backend/__tests__/notifications/BackupFailedNotification.test.tsindex 5a0e952..28bd614 100644--- a/backend/__tests__/notifications/BackupFailedNotification.test.ts+++ b/backend/__tests__/notifications/BackupFailedNotification.test.ts@@ -313,4 +313,200 @@ describe('BackupFailedNotification', () => {expect(content.stats).toBeUndefined();});});++ describe('buildSlackContent', () => {+ it('should build valid Slack Block Kit payload', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Connection timeout',+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.blocks).toBeDefined();+ expect(Array.isArray(content.blocks)).toBe(true);+ });++ it('should include header block with failure emoji', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Connection timeout',+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const header = content.blocks.find((b: any) => b.type === 'header');+ expect(header).toBeDefined();+ expect(header.text.text).toContain('Backup Failed');+ expect(header.text.text).toContain(mockPlan.title);+ });++ it('should include error message in code block', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Connection timeout',+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const errorBlock = content.blocks.find(+ (b: any) => b.type === 'section' && b.text?.text?.includes('Error')+ );+ expect(errorBlock).toBeDefined();+ expect(errorBlock.text.text).toContain('Connection timeout');+ });++ it('should include plan details in section fields', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Error',+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const section = content.blocks.find((b: any) => b.type === 'section' && b.fields);+ expect(section).toBeDefined();+ const fieldTexts = section.fields.map((f: any) => f.text);+ expect(fieldTexts).toEqual(+ expect.arrayContaining([+ expect.stringContaining('Test Backup Plan'),+ expect.stringContaining('Test Device'),+ ])+ );+ });++ it('should include View Plan button when APP_URL is set', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Error',+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const actions = content.blocks.find((b: any) => b.type === 'actions');+ expect(actions).toBeDefined();+ expect(actions.elements[0].url).toContain(mockPlan.id);+ });+ });++ describe('buildDiscordContent', () => {+ it('should build valid Discord embed payload', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Connection timeout',+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds).toBeDefined();+ expect(content.embeds).toHaveLength(1);+ });++ it('should use red color for failure', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Error',+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].color).toBe(0xef4444);+ });++ it('should include error in embed fields', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Connection timeout',+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ const errorField = content.embeds[0].fields.find((f: any) => f.name === 'Error');+ expect(errorField).toBeDefined();+ expect(errorField.value).toContain('Connection timeout');+ });++ it('should include plan title in embed title', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Error',+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].title).toContain('Backup Failed');+ expect(content.embeds[0].title).toContain(mockPlan.title);+ });++ it('should include footer with app title', () => {+ const notification = new BackupFailedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ error: 'Error',+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].footer.text).toBe('Test App');+ });+ });});diff --git a/backend/__tests__/notifications/BackupNotification.test.ts b/backend/__tests__/notifications/BackupNotification.test.tsindex a52e942..d72385d 100644--- a/backend/__tests__/notifications/BackupNotification.test.ts+++ b/backend/__tests__/notifications/BackupNotification.test.ts@@ -1,5 +1,7 @@import { BackupNotification } from '../../src/notifications/BackupNotification';import { NotificationChannelResolver } from '../../src/notifications/channels/NotificationChannelResolver';+import { SlackChannel } from '../../src/notifications/channels/SlackChannel';+import { DiscordChannel } from '../../src/notifications/channels/DiscordChannel';import { BackupStartedNotification } from '../../src/notifications/templates/email/backup/BackupStartedNotification';import { BackupSuccessNotification } from '../../src/notifications/templates/email/backup/BackupSuccessNotification';import { BackupFailedNotification } from '../../src/notifications/templates/email/backup/BackupFailedNotification';@@ -9,6 +11,8 @@ import { configService } from '../../src/services/ConfigService';// Mock dependenciesjest.mock('../../src/notifications/channels/NotificationChannelResolver');+jest.mock('../../src/notifications/channels/SlackChannel');+jest.mock('../../src/notifications/channels/DiscordChannel');jest.mock('../../src/notifications/templates/email/backup/BackupStartedNotification');jest.mock('../../src/notifications/templates/email/backup/BackupSuccessNotification');jest.mock('../../src/notifications/templates/email/backup/BackupFailedNotification');@@ -137,6 +141,86 @@ describe('BackupNotification', () => {await backupNotification.send(mockPlan, 'failure');expect(sendEmailSpy).toHaveBeenCalledWith(mockPlan, 'failure', undefined);});++ it('should send slack when slack notification is enabled', async () => {+ const sendEmailSpy = jest.spyOn(backupNotification, 'sendEmail').mockResolvedValue();+ const sendSlackSpy = jest.spyOn(backupNotification, 'sendSlack').mockResolvedValue();+ mockPlan.settings.notification!.slack = {+ enabled: true,+ case: 'both',+ url: 'https://hooks.slack.com/services/T00/B00/xxxx',+ };++ await backupNotification.send(mockPlan, 'start', { id: 'backup-1' });++ expect(sendEmailSpy).toHaveBeenCalled();+ expect(sendSlackSpy).toHaveBeenCalledWith(mockPlan, 'start', { id: 'backup-1' });+ });++ it('should send discord when discord notification is enabled', async () => {+ const sendEmailSpy = jest.spyOn(backupNotification, 'sendEmail').mockResolvedValue();+ const sendDiscordSpy = jest.spyOn(backupNotification, 'sendDiscord').mockResolvedValue();+ mockPlan.settings.notification!.discord = {+ enabled: true,+ case: 'both',+ url: 'https://discord.com/api/webhooks/1234/abcd',+ };++ await backupNotification.send(mockPlan, 'success', { id: 'backup-1' });++ expect(sendEmailSpy).toHaveBeenCalled();+ expect(sendDiscordSpy).toHaveBeenCalledWith(mockPlan, 'success', { id: 'backup-1' });+ });++ it('should not send slack when slack notification is disabled', async () => {+ jest.spyOn(backupNotification, 'sendEmail').mockResolvedValue();+ const sendSlackSpy = jest.spyOn(backupNotification, 'sendSlack');+ mockPlan.settings.notification!.slack = {+ enabled: false,+ case: 'both',+ url: 'https://hooks.slack.com/services/T00/B00/xxxx',+ };++ await backupNotification.send(mockPlan, 'start');++ expect(sendSlackSpy).not.toHaveBeenCalled();+ });++ it('should not send discord when discord notification is disabled', async () => {+ jest.spyOn(backupNotification, 'sendEmail').mockResolvedValue();+ const sendDiscordSpy = jest.spyOn(backupNotification, 'sendDiscord');+ mockPlan.settings.notification!.discord = {+ enabled: false,+ case: 'both',+ url: 'https://discord.com/api/webhooks/1234/abcd',+ };++ await backupNotification.send(mockPlan, 'start');++ expect(sendDiscordSpy).not.toHaveBeenCalled();+ });++ it('should send all channels when all are enabled', async () => {+ const sendEmailSpy = jest.spyOn(backupNotification, 'sendEmail').mockResolvedValue();+ const sendSlackSpy = jest.spyOn(backupNotification, 'sendSlack').mockResolvedValue();+ const sendDiscordSpy = jest.spyOn(backupNotification, 'sendDiscord').mockResolvedValue();+ mockPlan.settings.notification!.slack = {+ enabled: true,+ case: 'both',+ url: 'https://hooks.slack.com/services/T00/B00/xxxx',+ };+ mockPlan.settings.notification!.discord = {+ enabled: true,+ case: 'both',+ url: 'https://discord.com/api/webhooks/1234/abcd',+ };++ await backupNotification.send(mockPlan, 'start');++ expect(sendEmailSpy).toHaveBeenCalled();+ expect(sendSlackSpy).toHaveBeenCalled();+ expect(sendDiscordSpy).toHaveBeenCalled();+ });});describe('sendEmail', () => {@@ -201,6 +285,176 @@ describe('BackupNotification', () => {);});});+ describe('sendSlack', () => {+ let mockSlackChannel: any;++ beforeEach(() => {+ mockSlackChannel = {+ send: jest.fn().mockResolvedValue({ success: true, result: 'Sent' }),+ };+ (SlackChannel as jest.MockedClass<typeof SlackChannel>).mockImplementation(+ () => mockSlackChannel+ );+ mockPlan.settings.notification!.slack = {+ enabled: true,+ case: 'both',+ url: 'https://hooks.slack.com/services/T00/B00/xxxx',+ };+ });++ it('should send slack notification successfully', async () => {+ await backupNotification.sendSlack(mockPlan, 'success', { id: 'backup-1' });++ expect(SlackChannel).toHaveBeenCalledWith('https://hooks.slack.com/services/T00/B00/xxxx');+ expect(mockSlackChannel.send).toHaveBeenCalled();+ expect(mockLogger.info).toHaveBeenCalledWith(+ expect.stringContaining('Slack Notification Sent Successfully')+ );+ });++ it('should not send when notification case does not match', async () => {+ mockPlan.settings.notification!.slack!.case = 'end';++ 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')+ );+ });++ it('should throw error when webhook URL is missing', async () => {+ mockPlan.settings.notification!.slack!.url = '' as any;++ await backupNotification.sendSlack(mockPlan, 'success', { id: 'backup-1' });++ expect(mockSlackChannel.send).not.toHaveBeenCalled();+ expect(mockLogger.error).toHaveBeenCalledWith(+ expect.stringContaining('Slack Webhook URL Missing')+ );+ });++ it('should log error when channel send fails', async () => {+ mockSlackChannel.send.mockResolvedValue({ success: false, result: 'Send failed' });++ await backupNotification.sendSlack(mockPlan, 'success', { id: 'backup-1' });++ expect(mockLogger.error).toHaveBeenCalledWith(expect.stringContaining('Send failed'));+ });++ it('should handle channel errors gracefully', async () => {+ mockSlackChannel.send.mockRejectedValue(new Error('Network error'));++ await backupNotification.sendSlack(mockPlan, 'success', { id: 'backup-1' });++ expect(mockLogger.error).toHaveBeenCalledWith(expect.stringContaining('Network error'));+ });++ it('should bypass case check when notificationCase is provided', async () => {+ mockPlan.settings.notification!.slack!.case = 'end';++ await backupNotification.sendSlack(mockPlan, 'start', { id: 'backup-1' }, 'start');++ expect(mockSlackChannel.send).toHaveBeenCalled();+ expect(mockLogger.info).toHaveBeenCalledWith(+ expect.stringContaining('Slack Notification Sent Successfully')+ );+ });++ it('should pass slack as output format to getNotificationClass', async () => {+ await backupNotification.sendSlack(mockPlan, 'start', { startTime: new Date() });++ expect(BackupStartedNotification).toHaveBeenCalledWith(+ expect.objectContaining({ output: 'slack' })+ );+ });+ });++ describe('sendDiscord', () => {+ let mockDiscordChannel: any;++ beforeEach(() => {+ mockDiscordChannel = {+ send: jest.fn().mockResolvedValue({ success: true, result: 'Sent' }),+ };+ (DiscordChannel as jest.MockedClass<typeof DiscordChannel>).mockImplementation(+ () => mockDiscordChannel+ );+ mockPlan.settings.notification!.discord = {+ enabled: true,+ case: 'both',+ url: 'https://discord.com/api/webhooks/1234/abcd',+ };+ });++ it('should send discord notification successfully', async () => {+ await backupNotification.sendDiscord(mockPlan, 'success', { id: 'backup-1' });++ expect(DiscordChannel).toHaveBeenCalledWith('https://discord.com/api/webhooks/1234/abcd');+ expect(mockDiscordChannel.send).toHaveBeenCalled();+ expect(mockLogger.info).toHaveBeenCalledWith(+ expect.stringContaining('Discord Notification Sent Successfully')+ );+ });++ it('should not send when notification case does not match', async () => {+ mockPlan.settings.notification!.discord!.case = 'end';++ 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')+ );+ });++ it('should throw error when webhook URL is missing', async () => {+ mockPlan.settings.notification!.discord!.url = '' as any;++ await backupNotification.sendDiscord(mockPlan, 'success', { id: 'backup-1' });++ expect(mockDiscordChannel.send).not.toHaveBeenCalled();+ expect(mockLogger.error).toHaveBeenCalledWith(+ expect.stringContaining('Discord Webhook URL Missing')+ );+ });++ it('should log error when channel send fails', async () => {+ mockDiscordChannel.send.mockResolvedValue({ success: false, result: 'Send failed' });++ await backupNotification.sendDiscord(mockPlan, 'success', { id: 'backup-1' });++ expect(mockLogger.error).toHaveBeenCalledWith(expect.stringContaining('Send failed'));+ });++ it('should handle channel errors gracefully', async () => {+ mockDiscordChannel.send.mockRejectedValue(new Error('Network error'));++ await backupNotification.sendDiscord(mockPlan, 'success', { id: 'backup-1' });++ expect(mockLogger.error).toHaveBeenCalledWith(expect.stringContaining('Network error'));+ });++ it('should bypass case check when notificationCase is provided', async () => {+ mockPlan.settings.notification!.discord!.case = 'end';++ await backupNotification.sendDiscord(mockPlan, 'start', { id: 'backup-1' }, 'start');++ expect(mockDiscordChannel.send).toHaveBeenCalled();+ expect(mockLogger.info).toHaveBeenCalledWith(+ expect.stringContaining('Discord Notification Sent Successfully')+ );+ });++ it('should pass discord as output format to getNotificationClass', async () => {+ await backupNotification.sendDiscord(mockPlan, 'start', { startTime: new Date() });++ expect(BackupStartedNotification).toHaveBeenCalledWith(+ expect.objectContaining({ output: 'discord' })+ );+ });+ });+describe('getNotificationClass', () => {it('should return BackupStartedNotification for start type', async () => {const result = await backupNotification.getNotificationClass(mockPlan, 'start', {diff --git a/backend/__tests__/notifications/BackupStartedNotification.test.ts b/backend/__tests__/notifications/BackupStartedNotification.test.tsindex 2ca1434..f177fa2 100644--- a/backend/__tests__/notifications/BackupStartedNotification.test.ts+++ b/backend/__tests__/notifications/BackupStartedNotification.test.ts@@ -348,4 +348,180 @@ describe('BackupStartedNotification', () => {expect(content.storagePath).toBe('');});});++ describe('buildSlackContent', () => {+ it('should build valid Slack Block Kit payload', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.blocks).toBeDefined();+ expect(Array.isArray(content.blocks)).toBe(true);+ });++ it('should include header block with started emoji', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const header = content.blocks.find((b: any) => b.type === 'header');+ expect(header).toBeDefined();+ expect(header.text.text).toContain('Backup Started');+ expect(header.text.text).toContain(mockPlan.title);+ });++ it('should include plan details in section fields', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const section = content.blocks.find((b: any) => b.type === 'section' && b.fields);+ expect(section).toBeDefined();+ const fieldTexts = section.fields.map((f: any) => f.text);+ expect(fieldTexts).toEqual(+ expect.arrayContaining([+ expect.stringContaining('Test Backup Plan'),+ expect.stringContaining('Test Device'),+ expect.stringContaining('Test Storage'),+ ])+ );+ });++ it('should include View Plan button when APP_URL is set', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const actions = content.blocks.find((b: any) => b.type === 'actions');+ expect(actions).toBeDefined();+ expect(actions.elements[0].url).toContain(mockPlan.id);+ });++ it('should include context with app title', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const context = content.blocks.find((b: any) => b.type === 'context');+ expect(context).toBeDefined();+ expect(context.elements[0].text).toContain('Test App');+ });+ });++ describe('buildDiscordContent', () => {+ it('should build valid Discord embed payload', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds).toBeDefined();+ expect(content.embeds).toHaveLength(1);+ });++ it('should use blue color for started', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].color).toBe(0x3b82f6);+ });++ it('should include plan details as embed fields', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ const fieldNames = content.embeds[0].fields.map((f: any) => f.name);+ expect(fieldNames).toContain('Plan');+ expect(fieldNames).toContain('Method');+ expect(fieldNames).toContain('Device');+ expect(fieldNames).toContain('Storage');+ });++ it('should include plan URL when APP_URL is set', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].url).toContain(mockPlan.id);+ });++ it('should include footer with app title', () => {+ const notification = new BackupStartedNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].footer.text).toBe('Test App');+ });+ });});diff --git a/backend/__tests__/notifications/BackupSuccessNotification.test.ts b/backend/__tests__/notifications/BackupSuccessNotification.test.tsindex 43ee44b..87726ca 100644--- a/backend/__tests__/notifications/BackupSuccessNotification.test.ts+++ b/backend/__tests__/notifications/BackupSuccessNotification.test.ts@@ -290,4 +290,324 @@ describe('BackupSuccessNotification', () => {expect(content.planSource.excluded).toBe('');});});++ describe('buildSlackContent', () => {+ it('should build valid Slack Block Kit payload', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.blocks).toBeDefined();+ expect(Array.isArray(content.blocks)).toBe(true);+ });++ it('should include header block with success emoji', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const header = content.blocks.find((b: any) => b.type === 'header');+ expect(header).toBeDefined();+ expect(header.text.text).toContain('Backup Complete');+ expect(header.text.text).toContain(mockPlan.title);+ });++ it('should include plan details in section fields', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const section = content.blocks.find((b: any) => b.type === 'section' && b.fields);+ expect(section).toBeDefined();+ const fieldTexts = section.fields.map((f: any) => f.text);+ expect(fieldTexts).toEqual(+ expect.arrayContaining([+ expect.stringContaining('Test Backup Plan'),+ expect.stringContaining('Test Device'),+ expect.stringContaining('Test Storage'),+ ])+ );+ });++ it('should include stats fields when provided', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ stats: {+ total_files_processed: 100,+ total_bytes_processed: 2048000,+ total_duration: 120,+ } as any,+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const section = content.blocks.find((b: any) => b.type === 'section' && b.fields);+ const fieldTexts = section.fields.map((f: any) => f.text);+ expect(fieldTexts).toEqual(+ expect.arrayContaining([+ expect.stringContaining('Files'),+ expect.stringContaining('Size'),+ expect.stringContaining('Duration'),+ ])+ );+ });++ it('should include replication failures when present', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ replicationFailures: [+ { storageName: 'Mirror-1', storageId: 'mirror-1', error: 'Connection failed' },+ ] as any,+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const replicationBlock = content.blocks.find(+ (b: any) => b.type === 'section' && b.text?.text?.includes('Replication')+ );+ expect(replicationBlock).toBeDefined();+ expect(replicationBlock.text.text).toContain('Mirror-1');+ });++ it('should include View Plan button when APP_URL is set', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const actions = content.blocks.find((b: any) => b.type === 'actions');+ expect(actions).toBeDefined();+ expect(actions.elements[0].text.text).toBe('View Plan');+ expect(actions.elements[0].url).toContain(mockPlan.id);+ });++ it('should include context block with app title', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'slack',+ });++ const content = JSON.parse(notification.getContent());+ const context = content.blocks.find((b: any) => b.type === 'context');+ expect(context).toBeDefined();+ expect(context.elements[0].text).toContain('Test App');+ });+ });++ describe('buildDiscordContent', () => {+ it('should build valid Discord embed payload', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds).toBeDefined();+ expect(content.embeds).toHaveLength(1);+ });++ it('should use green color for success', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].color).toBe(0x22c55e);+ });++ it('should include plan title in embed title', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].title).toContain('Backup Complete');+ expect(content.embeds[0].title).toContain(mockPlan.title);+ });++ it('should include plan details as embed fields', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ const fieldNames = content.embeds[0].fields.map((f: any) => f.name);+ expect(fieldNames).toContain('Plan');+ expect(fieldNames).toContain('Method');+ expect(fieldNames).toContain('Device');+ expect(fieldNames).toContain('Storage');+ });++ it('should include stats fields when provided', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ stats: {+ total_files_processed: 100,+ total_bytes_processed: 2048000,+ total_duration: 120,+ } as any,+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ const fieldNames = content.embeds[0].fields.map((f: any) => f.name);+ expect(fieldNames).toContain('Files');+ expect(fieldNames).toContain('Size');+ expect(fieldNames).toContain('Duration');+ });++ it('should include replication failures field when present', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ replicationFailures: [+ { storageName: 'Mirror-1', storageId: 'mirror-1', error: 'Connection failed' },+ ] as any,+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ const replicationField = content.embeds[0].fields.find((f: any) =>+ f.name.includes('Replication')+ );+ expect(replicationField).toBeDefined();+ expect(replicationField.value).toContain('Mirror-1');+ });++ it('should include plan URL when APP_URL is set', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].url).toContain(mockPlan.id);+ });++ it('should include footer with app title', () => {+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime: new Date(),+ endTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].footer.text).toBe('Test App');+ });++ it('should include ISO timestamp', () => {+ const startTime = new Date('2024-01-15T10:00:00Z');+ const notification = new BackupSuccessNotification({+ appTitle: 'Test App',+ deviceName: 'Test Device',+ storageName: 'Test Storage',+ storageType: 's3',+ plan: mockPlan,+ startTime,+ endTime: new Date(),+ output: 'discord',+ });++ const content = JSON.parse(notification.getContent());+ expect(content.embeds[0].timestamp).toBe(startTime.toISOString());+ });+ });});diff --git a/backend/__tests__/notifications/DiscordChannel.test.ts b/backend/__tests__/notifications/DiscordChannel.test.tsnew file mode 100644index 0000000..556ab61--- /dev/null+++ b/backend/__tests__/notifications/DiscordChannel.test.ts@@ -0,0 +1,189 @@+import { DiscordChannel } from '../../src/notifications/channels/DiscordChannel';+import { BaseNotification } from '../../src/notifications/BaseNotification';++// Mock global fetch+const mockFetch = jest.fn();+global.fetch = mockFetch;++// Mock notification for testing+class MockNotification extends BaseNotification {+ constructor(content: string = '{"content":"Test message"}', subject: string = 'Test Subject') {+ super();+ this.subject = subject;+ this.content = content;+ }++ protected buildContent(): string {+ return '';+ }+}++describe('DiscordChannel', () => {+ let discordChannel: DiscordChannel;+ const webhookUrl = 'https://discord.com/api/webhooks/1234567890/abcdefghijk';++ beforeEach(() => {+ jest.clearAllMocks();+ discordChannel = new DiscordChannel(webhookUrl);+ });++ describe('constructor', () => {+ it('should create instance with webhook URL', () => {+ expect(discordChannel).toBeInstanceOf(DiscordChannel);+ expect(discordChannel['webhookUrl']).toBe(webhookUrl);+ });+ });++ describe('send', () => {+ it('should send notification successfully with JSON content', async () => {+ mockFetch.mockResolvedValue({+ ok: true,+ text: jest.fn().mockResolvedValue(''),+ });++ const payload = JSON.stringify({+ embeds: [+ {+ title: '✅ Backup Complete',+ color: 0x22c55e,+ fields: [{ name: 'Plan', value: 'Test Plan', inline: true }],+ },+ ],+ });+ const notification = new MockNotification(payload);++ const result = await discordChannel.send(notification);++ expect(result).toEqual({+ success: true,+ result: 'Discord notification sent successfully',+ });+ expect(mockFetch).toHaveBeenCalledWith(webhookUrl, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: payload,+ });+ });++ it('should wrap plain text content in Discord message format', async () => {+ mockFetch.mockResolvedValue({+ ok: true,+ text: jest.fn().mockResolvedValue(''),+ });++ const notification = new MockNotification('Plain text message');++ await discordChannel.send(notification);++ expect(mockFetch).toHaveBeenCalledWith(webhookUrl, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ content: 'Plain text message' }),+ });+ });++ it('should return failure when webhook returns non-ok response', async () => {+ mockFetch.mockResolvedValue({+ ok: false,+ status: 404,+ text: jest.fn().mockResolvedValue('Unknown Webhook'),+ });++ const notification = new MockNotification();++ const result = await discordChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'Discord webhook returned 404: Unknown Webhook',+ });+ });++ it('should return failure when webhook is rate limited', async () => {+ mockFetch.mockResolvedValue({+ ok: false,+ status: 429,+ text: jest.fn().mockResolvedValue('You are being rate limited.'),+ });++ const notification = new MockNotification();++ const result = await discordChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'Discord webhook returned 429: You are being rate limited.',+ });+ });++ it('should handle network errors gracefully', async () => {+ mockFetch.mockRejectedValue(new Error('Network error'));++ const notification = new MockNotification();++ const result = await discordChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'Network error',+ });+ });++ it('should handle unknown errors', async () => {+ mockFetch.mockRejectedValue('unexpected');++ const notification = new MockNotification();++ const result = await discordChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'Failed to send Discord notification',+ });+ });++ it('should send with embed payload', async () => {+ mockFetch.mockResolvedValue({+ ok: true,+ text: jest.fn().mockResolvedValue(''),+ });++ const embeds = {+ embeds: [+ {+ title: '❌ Backup Failed: Production Plan',+ color: 0xef4444,+ fields: [+ { name: 'Plan', value: 'Production Plan', inline: true },+ { name: 'Error', value: '```Connection timeout```', inline: false },+ ],+ timestamp: '2024-01-15T10:00:00.000Z',+ footer: { text: 'Pluton' },+ },+ ],+ };+ const notification = new MockNotification(JSON.stringify(embeds));++ await discordChannel.send(notification);++ const callBody = JSON.parse(mockFetch.mock.calls[0][1].body);+ expect(callBody.embeds).toHaveLength(1);+ expect(callBody.embeds[0].color).toBe(0xef4444);+ expect(callBody.embeds[0].fields).toHaveLength(2);+ });++ it('should pass options to send method', async () => {+ mockFetch.mockResolvedValue({+ ok: true,+ text: jest.fn().mockResolvedValue(''),+ });++ const notification = new MockNotification();+ const options = { username: 'Pluton Bot' };++ const result = await discordChannel.send(notification, options);++ expect(result.success).toBe(true);+ });+ });+});diff --git a/backend/__tests__/notifications/SlackChannel.test.ts b/backend/__tests__/notifications/SlackChannel.test.tsnew file mode 100644index 0000000..50f43c7--- /dev/null+++ b/backend/__tests__/notifications/SlackChannel.test.ts@@ -0,0 +1,196 @@+import { SlackChannel } from '../../src/notifications/channels/SlackChannel';+import { BaseNotification } from '../../src/notifications/BaseNotification';++// Mock global fetch+const mockFetch = jest.fn();+global.fetch = mockFetch;++// Mock notification for testing+class MockNotification extends BaseNotification {+ constructor(content: string = '{"text":"Test message"}', subject: string = 'Test Subject') {+ super();+ this.subject = subject;+ this.content = content;+ }++ protected buildContent(): string {+ return '';+ }+}++describe('SlackChannel', () => {+ let slackChannel: SlackChannel;+ const webhookUrl = 'https://hooks.slack.com/services/T00/B00/xxxx';++ beforeEach(() => {+ jest.clearAllMocks();+ slackChannel = new SlackChannel(webhookUrl);+ });++ describe('constructor', () => {+ it('should create instance with webhook URL', () => {+ expect(slackChannel).toBeInstanceOf(SlackChannel);+ expect(slackChannel['webhookUrl']).toBe(webhookUrl);+ });+ });++ describe('send', () => {+ it('should send notification successfully with JSON content', async () => {+ mockFetch.mockResolvedValue({+ ok: true,+ text: jest.fn().mockResolvedValue('ok'),+ });++ const payload = JSON.stringify({+ blocks: [{ type: 'section', text: { type: 'mrkdwn', text: 'Test' } }],+ });+ const notification = new MockNotification(payload);++ const result = await slackChannel.send(notification);++ expect(result).toEqual({+ success: true,+ result: 'Slack notification sent successfully',+ });+ expect(mockFetch).toHaveBeenCalledWith(webhookUrl, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: payload,+ });+ });++ it('should wrap plain text content in Slack message format', async () => {+ mockFetch.mockResolvedValue({+ ok: true,+ text: jest.fn().mockResolvedValue('ok'),+ });++ const notification = new MockNotification('Plain text message');++ await slackChannel.send(notification);++ expect(mockFetch).toHaveBeenCalledWith(webhookUrl, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify({ text: 'Plain text message' }),+ });+ });++ it('should return failure when webhook returns non-ok response', async () => {+ mockFetch.mockResolvedValue({+ ok: false,+ status: 404,+ text: jest.fn().mockResolvedValue('channel_not_found'),+ });++ const notification = new MockNotification();++ const result = await slackChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'Slack webhook returned 404: channel_not_found',+ });+ });++ it('should return failure when webhook returns 403', async () => {+ mockFetch.mockResolvedValue({+ ok: false,+ status: 403,+ text: jest.fn().mockResolvedValue('invalid_token'),+ });++ const notification = new MockNotification();++ const result = await slackChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'Slack webhook returned 403: invalid_token',+ });+ });++ it('should handle network errors gracefully', async () => {+ mockFetch.mockRejectedValue(new Error('Network error'));++ const notification = new MockNotification();++ const result = await slackChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'Network error',+ });+ });++ it('should handle timeout errors', async () => {+ mockFetch.mockRejectedValue(new Error('The operation was aborted'));++ const notification = new MockNotification();++ const result = await slackChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'The operation was aborted',+ });+ });++ it('should handle unknown errors', async () => {+ mockFetch.mockRejectedValue('unexpected');++ const notification = new MockNotification();++ const result = await slackChannel.send(notification);++ expect(result).toEqual({+ success: false,+ result: 'Failed to send Slack notification',+ });+ });++ it('should send with Block Kit payload', async () => {+ mockFetch.mockResolvedValue({+ ok: true,+ text: jest.fn().mockResolvedValue('ok'),+ });++ const blocks = {+ blocks: [+ {+ type: 'header',+ text: { type: 'plain_text', text: '✅ Backup Complete: Test Plan' },+ },+ {+ type: 'section',+ fields: [+ { type: 'mrkdwn', text: '*Plan:* Test Plan' },+ { type: 'mrkdwn', text: '*Device:* Server-1' },+ ],+ },+ ],+ };+ const notification = new MockNotification(JSON.stringify(blocks));++ await slackChannel.send(notification);++ const callBody = JSON.parse(mockFetch.mock.calls[0][1].body);+ expect(callBody.blocks).toHaveLength(2);+ expect(callBody.blocks[0].type).toBe('header');+ });++ it('should pass options to send method', async () => {+ mockFetch.mockResolvedValue({+ ok: true,+ text: jest.fn().mockResolvedValue('ok'),+ });++ const notification = new MockNotification();+ const options = { channel: '#backups' };++ const result = await slackChannel.send(notification, options);++ expect(result.success).toBe(true);+ });+ });+});diff --git a/backend/src/controllers/PlanController.ts b/backend/src/controllers/PlanController.tsindex 50dda4b..713d174 100644--- a/backend/src/controllers/PlanController.ts+++ b/backend/src/controllers/PlanController.ts@@ -364,4 +364,37 @@ export class PlanController {return;}}++ async sendTestBackupNotification(req: Request, res: Response): Promise<void> {+ if (+ !req.body.planId ||+ !req.body.notificationCase ||+ !req.body.channelSettings ||+ !req.body.notificationChannel+ ) {+ console.log('req.body :', req.body);+ res.status(400).json({+ success: false,+ error: 'Payload Missing.',+ });+ return;+ }++ try {+ const notificationChannel = req.body.notificationChannel as 'slack' | 'discord' | 'webhook';+ await this.planService.sendTestNotification(+ req.body.planId,+ notificationChannel,+ req.body.notificationCase,+ req.body.channelSettings+ );+ res.status(200).json({ success: true, message: 'Test notification sent successfully' });+ } catch (error: unknown) {+ const appError = error as AppError;+ res.status(appError.statusCode || 500).json({+ success: false,+ error: appError?.message || 'Failed to send test notification',+ });+ }+ }}diff --git a/backend/src/notifications/BackupNotification.ts b/backend/src/notifications/BackupNotification.tsindex c27bd52..52a1dde 100644--- a/backend/src/notifications/BackupNotification.ts+++ b/backend/src/notifications/BackupNotification.ts@@ -7,6 +7,8 @@ import { BackupFailedNotification } from './templates/email/backup/BackupFailedNimport { ReplicationFailedNotification } from './templates/email/backup/ReplicationFailedNotification';import { planLogger } from '../utils/logger';import { NotificationChannelResolver } from '../notifications/channels/NotificationChannelResolver';+import { SlackChannel } from '../notifications/channels/SlackChannel';+import { DiscordChannel } from '../notifications/channels/DiscordChannel';import { configService } from '../services/ConfigService';interface BackupDataType {@@ -41,6 +43,12 @@ export class BackupNotification {if (notification?.email?.enabled) {await this.sendEmail(plan, notificationType, backupData);}+ if (notification?.slack?.enabled) {+ await this.sendSlack(plan, notificationType, backupData);+ }+ if (notification?.discord?.enabled) {+ await this.sendDiscord(plan, notificationType, backupData);+ }}async sendEmail(@@ -82,11 +90,88 @@ export class BackupNotification {}}+ async sendSlack(+ plan: PlanFull,+ notificationType: NotificationType,+ backupData?: BackupDataType,+ notificationCase?: string+ ) {+ try {+ 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.');++ const webhookUrl = notification?.slack?.url;+ if (!webhookUrl) throw new Error('Slack Webhook URL Missing.');++ const slackChannel = new SlackChannel(webhookUrl);+ const notificationClass = await this.getNotificationClass(+ plan,+ notificationType,+ backupData,+ 'slack'+ );+ const notificationResult = await slackChannel.send(notificationClass);++ if (!notificationResult?.success)+ throw new Error(notificationResult?.result || 'Unknown Error');++ planLogger('notification', plan.id, backupData?.id).info(+ `Backup ${notificationType} Slack Notification Sent Successfully.`+ );+ } catch (error) {+ const errorMessage = error instanceof Error ? error.message : 'Unknown Error.';+ planLogger('notification', plan.id, backupData?.id).error(+ `Error Sending Backup ${notificationType} Slack Notification. Reason: ${errorMessage}`+ );+ }+ }++ async sendDiscord(+ plan: PlanFull,+ notificationType: NotificationType,+ backupData?: BackupDataType,+ notificationCase?: string+ ) {+ try {+ 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.');++ const webhookUrl = notification?.discord?.url;+ if (!webhookUrl) throw new Error('Discord Webhook URL Missing.');++ const discordChannel = new DiscordChannel(webhookUrl);+ const notificationClass = await this.getNotificationClass(+ plan,+ notificationType,+ backupData,+ 'discord'+ );+ const notificationResult = await discordChannel.send(notificationClass);++ if (!notificationResult?.success)+ throw new Error(notificationResult?.result || 'Unknown Error');++ planLogger('notification', plan.id, backupData?.id).info(+ `Backup ${notificationType} Discord Notification Sent Successfully.`+ );+ } catch (error) {+ const errorMessage = error instanceof Error ? error.message : 'Unknown Error.';+ planLogger('notification', plan.id, backupData?.id).error(+ `Error Sending Backup ${notificationType} Discord Notification. Reason: ${errorMessage}`+ );+ }+ }+async getNotificationClass(plan: PlanFull,notificationType: NotificationType,backupData?: BackupDataType,- output: 'html' | 'json' | 'push' = 'html'+ output: 'html' | 'json' | 'push' | 'slack' | 'discord' = 'html') {let notificationClass;const deviceName = plan.device?.name || '';diff --git a/backend/src/notifications/channels/DiscordChannel.ts b/backend/src/notifications/channels/DiscordChannel.tsnew file mode 100644index 0000000..c08c289--- /dev/null+++ b/backend/src/notifications/channels/DiscordChannel.ts@@ -0,0 +1,51 @@+import { BaseNotification } from '../BaseNotification';+import { NotificationChannel } from '../NotificationChannel';++export class DiscordChannel implements NotificationChannel {+ private webhookUrl: string;++ constructor(webhookUrl: string) {+ this.webhookUrl = webhookUrl;+ }++ async send(+ notification: BaseNotification,+ options?: Record<string, any>+ ): Promise<{ success: boolean; result: string }> {+ try {+ const content = notification.getContent();+ let payload: Record<string, any>;++ try {+ payload = JSON.parse(content);+ } catch {+ // If content is plain text, wrap it in a Discord message format+ payload = { content };+ }++ const response = await fetch(this.webhookUrl, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify(payload),+ });++ if (!response.ok) {+ const errorText = await response.text();+ return {+ success: false,+ result: `Discord webhook returned ${response.status}: ${errorText}`,+ };+ }++ return {+ success: true,+ result: 'Discord notification sent successfully',+ };+ } catch (error: any) {+ return {+ success: false,+ result: error?.message || 'Failed to send Discord notification',+ };+ }+ }+}diff --git a/backend/src/notifications/channels/SlackChannel.ts b/backend/src/notifications/channels/SlackChannel.tsnew file mode 100644index 0000000..b5bcabe--- /dev/null+++ b/backend/src/notifications/channels/SlackChannel.ts@@ -0,0 +1,51 @@+import { BaseNotification } from '../BaseNotification';+import { NotificationChannel } from '../NotificationChannel';++export class SlackChannel implements NotificationChannel {+ private webhookUrl: string;++ constructor(webhookUrl: string) {+ this.webhookUrl = webhookUrl;+ }++ async send(+ notification: BaseNotification,+ options?: Record<string, any>+ ): Promise<{ success: boolean; result: string }> {+ try {+ const content = notification.getContent();+ let payload: Record<string, any>;++ try {+ payload = JSON.parse(content);+ } catch {+ // If content is plain text, wrap it in a Slack message format+ payload = { text: content };+ }++ const response = await fetch(this.webhookUrl, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' },+ body: JSON.stringify(payload),+ });++ if (!response.ok) {+ const errorText = await response.text();+ return {+ success: false,+ result: `Slack webhook returned ${response.status}: ${errorText}`,+ };+ }++ return {+ success: true,+ result: 'Slack notification sent successfully',+ };+ } catch (error: any) {+ return {+ success: false,+ result: error?.message || 'Failed to send Slack notification',+ };+ }+ }+}diff --git a/backend/src/notifications/templates/email/backup/BackupFailedNotification.ts b/backend/src/notifications/templates/email/backup/BackupFailedNotification.tsindex 822b71f..c4487dc 100644--- a/backend/src/notifications/templates/email/backup/BackupFailedNotification.ts+++ b/backend/src/notifications/templates/email/backup/BackupFailedNotification.ts@@ -17,7 +17,7 @@ export interface BackupFailedNotificationPayload {endTime: Date;error: string;stats?: BackupTaskStats;- output?: 'html' | 'json' | 'push';+ output?: 'html' | 'json' | 'push' | 'slack' | 'discord';}export class BackupFailedNotification extends BaseNotification {@@ -32,6 +32,12 @@ export class BackupFailedNotification extends BaseNotification {if (this.contentType === 'json') {return this.buildJSONContent(data);}+ if (this.contentType === 'slack') {+ return this.buildSlackContent(data);+ }+ if (this.contentType === 'discord') {+ return this.buildDiscordContent(data);+ }return this.buildHTMLContent(data);}@@ -115,4 +121,82 @@ export class BackupFailedNotification extends BaseNotification {className: 'content--error',});}++ protected buildSlackContent(data: BackupFailedNotificationPayload): string {+ const { appTitle, deviceName, storageName, storageType, plan, error, startTime, endTime } =+ data;+ const storageTypeName = storageType ? providers[storageType]?.name || storageType : '';+ const appUrl = configService.config.APP_URL || '';++ const fields: { type: string; text: string }[] = [+ { type: 'mrkdwn', text: `*Plan:* ${plan.title}` },+ { type: 'mrkdwn', text: `*Method:* ${plan.method}` },+ { type: 'mrkdwn', text: `*Device:* ${deviceName}` },+ { type: 'mrkdwn', text: `*Storage:* ${storageName} (${storageTypeName})` },+ ];++ const blocks: Record<string, any>[] = [+ {+ type: 'header',+ text: { type: 'plain_text', text: `❌ Backup Failed: ${plan.title}`, emoji: true },+ },+ {+ type: 'section',+ fields,+ },+ {+ type: 'section',+ text: { type: 'mrkdwn', text: `*Error:*\n\`\`\`${error}\`\`\`` },+ },+ ];++ if (appUrl) {+ blocks.push({+ type: 'actions',+ elements: [+ {+ type: 'button',+ text: { type: 'plain_text', text: 'View Plan', emoji: true },+ url: `${appUrl}/plan/${plan.id}`,+ },+ ],+ });+ }++ blocks.push({+ type: 'context',+ elements: [{ type: 'mrkdwn', text: `${appTitle} • ${new Date(startTime).toLocaleString()}` }],+ });++ return JSON.stringify({ blocks });+ }++ protected buildDiscordContent(data: BackupFailedNotificationPayload): string {+ const { appTitle, deviceName, storageName, storageType, plan, error, startTime, endTime } =+ data;+ const storageTypeName = storageType ? providers[storageType]?.name || storageType : '';+ const appUrl = configService.config.APP_URL || '';++ const fields: { name: string; value: string; inline: boolean }[] = [+ { name: 'Plan', value: plan.title, inline: true },+ { name: 'Method', value: plan.method, inline: true },+ { name: 'Device', value: deviceName, inline: true },+ { name: 'Storage', value: `${storageName} (${storageTypeName})`, inline: true },+ { name: 'Error', value: `\`\`\`${error}\`\`\``, inline: false },+ ];++ const embed: Record<string, any> = {+ title: `❌ Backup Failed: ${plan.title}`,+ color: 0xef4444, // red+ fields,+ timestamp: new Date(startTime).toISOString(),+ footer: { text: appTitle },+ };++ if (appUrl) {+ embed.url = `${appUrl}/plan/${plan.id}`;+ }++ return JSON.stringify({ embeds: [embed] });+ }}diff --git a/backend/src/notifications/templates/email/backup/BackupStartedNotification.ts b/backend/src/notifications/templates/email/backup/BackupStartedNotification.tsindex b75c4f8..09ba35c 100644--- a/backend/src/notifications/templates/email/backup/BackupStartedNotification.ts+++ b/backend/src/notifications/templates/email/backup/BackupStartedNotification.ts@@ -30,6 +30,12 @@ export class BackupStartedNotification extends BaseNotification {if (this.contentType === 'json') {return this.buildJSONContent(data);}+ if (this.contentType === 'slack') {+ return this.buildSlackContent(data);+ }+ if (this.contentType === 'discord') {+ return this.buildDiscordContent(data);+ }return this.buildHTMLContent(data);}@@ -92,4 +98,75 @@ export class BackupStartedNotification extends BaseNotification {preHeader: `Backup Started: ${data.plan.title}`,});}++ protected buildSlackContent(data: BackupStartedPayload): string {+ const { appTitle, deviceName, storageName, storageType, plan, startTime } = data;+ const storageTypeName = storageType ? providers[storageType]?.name || storageType : '';+ const appUrl = configService.config.APP_URL || '';++ const fields: { type: string; text: string }[] = [+ { type: 'mrkdwn', text: `*Plan:* ${plan.title}` },+ { type: 'mrkdwn', text: `*Method:* ${plan.method}` },+ { type: 'mrkdwn', text: `*Device:* ${deviceName}` },+ { type: 'mrkdwn', text: `*Storage:* ${storageName} (${storageTypeName})` },+ ];++ const blocks: Record<string, any>[] = [+ {+ type: 'header',+ text: { type: 'plain_text', text: `🚀 Backup Started: ${plan.title}`, emoji: true },+ },+ {+ type: 'section',+ fields,+ },+ ];++ if (appUrl) {+ blocks.push({+ type: 'actions',+ elements: [+ {+ type: 'button',+ text: { type: 'plain_text', text: 'View Plan', emoji: true },+ url: `${appUrl}/plan/${plan.id}`,+ },+ ],+ });+ }++ blocks.push({+ type: 'context',+ elements: [{ type: 'mrkdwn', text: `${appTitle} • ${new Date(startTime).toLocaleString()}` }],+ });++ return JSON.stringify({ blocks });+ }++ protected buildDiscordContent(data: BackupStartedPayload): string {+ const { appTitle, deviceName, storageName, storageType, plan, startTime } = data;+ const storageTypeName = storageType ? providers[storageType]?.name || storageType : '';+ const appUrl = configService.config.APP_URL || '';++ const fields: { name: string; value: string; inline: boolean }[] = [+ { name: 'Plan', value: plan.title, inline: true },+ { name: 'Method', value: plan.method, inline: true },+ { name: 'Device', value: deviceName, inline: true },+ { name: 'Storage', value: `${storageName} (${storageTypeName})`, inline: true },+ ];++ const embed: Record<string, any> = {+ title: `🚀 Backup Started: ${plan.title}`,+ color: 0x3b82f6, // blue+ fields,+ timestamp: new Date(startTime).toISOString(),+ footer: { text: appTitle },+ };++ if (appUrl) {+ embed.url = `${appUrl}/plan/${plan.id}`;+ }++ return JSON.stringify({ embeds: [embed] });+ }}diff --git a/backend/src/notifications/templates/email/backup/BackupSuccessNotification.ts b/backend/src/notifications/templates/email/backup/BackupSuccessNotification.tsindex 3d05f6c..a8e87cf 100644--- a/backend/src/notifications/templates/email/backup/BackupSuccessNotification.ts+++ b/backend/src/notifications/templates/email/backup/BackupSuccessNotification.ts@@ -21,7 +21,7 @@ export interface BackupSuccessNotificationPayload {endTime: Date;stats?: BackupCompletionStats;replicationFailures?: ReplicationFailureInfo[];- output?: 'html' | 'json' | 'push';+ output?: 'html' | 'json' | 'push' | 'slack' | 'discord';}export class BackupSuccessNotification extends BaseNotification {@@ -36,6 +36,12 @@ export class BackupSuccessNotification extends BaseNotification {if (this.contentType === 'json') {return this.buildJSONContent(data);}+ if (this.contentType === 'slack') {+ return this.buildSlackContent(data);+ }+ if (this.contentType === 'discord') {+ return this.buildDiscordContent(data);+ }return this.buildHTMLContent(data);}@@ -118,4 +124,152 @@ export class BackupSuccessNotification extends BaseNotification {preHeader: `Backup Success: ${data.plan.title}`,});}++ protected buildSlackContent(data: BackupSuccessNotificationPayload): string {+ const {+ appTitle,+ deviceName,+ storageName,+ storageType,+ plan,+ stats,+ startTime,+ endTime,+ replicationFailures,+ } = data;+ const storageTypeName = storageType ? providers[storageType]?.name || storageType : '';+ const appUrl = configService.config.APP_URL || '';++ const fields: { type: string; text: string }[] = [+ { type: 'mrkdwn', text: `*Plan:* ${plan.title}` },+ { type: 'mrkdwn', text: `*Method:* ${plan.method}` },+ { type: 'mrkdwn', text: `*Device:* ${deviceName}` },+ { type: 'mrkdwn', text: `*Storage:* ${storageName} (${storageTypeName})` },+ ];++ if (stats) {+ if (stats.total_files_processed)+ fields.push({+ type: 'mrkdwn',+ text: `*Files:* ${formatNumberToK(stats.total_files_processed)}`,+ });+ if (stats.total_bytes_processed)+ fields.push({+ type: 'mrkdwn',+ text: `*Size:* ${formatBytes(stats.total_bytes_processed)}`,+ });+ if (stats.total_duration)+ fields.push({+ type: 'mrkdwn',+ text: `*Duration:* ${formatDuration(stats.total_duration)}`,+ });+ }++ const blocks: Record<string, any>[] = [+ {+ type: 'header',+ text: { type: 'plain_text', text: `✅ Backup Complete: ${plan.title}`, emoji: true },+ },+ {+ type: 'section',+ fields,+ },+ ];++ if (replicationFailures && replicationFailures.length > 0) {+ blocks.push({+ type: 'section',+ text: {+ type: 'mrkdwn',+ text: `⚠️ *Replication Failures:* ${replicationFailures.map(f => f.storageName || f.storageId).join(', ')}`,+ },+ });+ }++ if (appUrl) {+ blocks.push({+ type: 'actions',+ elements: [+ {+ type: 'button',+ text: { type: 'plain_text', text: 'View Plan', emoji: true },+ url: `${appUrl}/plan/${plan.id}`,+ },+ ],+ });+ }++ blocks.push({+ type: 'context',+ elements: [{ type: 'mrkdwn', text: `${appTitle} • ${new Date(startTime).toLocaleString()}` }],+ });++ return JSON.stringify({ blocks });+ }++ protected buildDiscordContent(data: BackupSuccessNotificationPayload): string {+ const {+ appTitle,+ deviceName,+ storageName,+ storageType,+ plan,+ stats,+ startTime,+ endTime,+ replicationFailures,+ } = data;+ const storageTypeName = storageType ? providers[storageType]?.name || storageType : '';+ const appUrl = configService.config.APP_URL || '';++ const fields: { name: string; value: string; inline: boolean }[] = [+ { name: 'Plan', value: plan.title, inline: true },+ { name: 'Method', value: plan.method, inline: true },+ { name: 'Device', value: deviceName, inline: true },+ { name: 'Storage', value: `${storageName} (${storageTypeName})`, inline: true },+ ];++ if (stats) {+ if (stats.total_files_processed)+ fields.push({+ name: 'Files',+ value: formatNumberToK(stats.total_files_processed).toString(),+ inline: true,+ });+ if (stats.total_bytes_processed)+ fields.push({+ name: 'Size',+ value: formatBytes(stats.total_bytes_processed),+ inline: true,+ });+ if (stats.total_duration)+ fields.push({+ name: 'Duration',+ value: formatDuration(stats.total_duration),+ inline: true,+ });+ }++ if (replicationFailures && replicationFailures.length > 0) {+ fields.push({+ name: '⚠️ Replication Failures',+ value: replicationFailures.map(f => f.storageName || f.storageId).join(', '),+ inline: false,+ });+ }++ const embed: Record<string, any> = {+ title: `✅ Backup Complete: ${plan.title}`,+ color: 0x22c55e, // green+ fields,+ timestamp: new Date(startTime).toISOString(),+ footer: { text: appTitle },+ };++ if (appUrl) {+ embed.url = `${appUrl}/plan/${plan.id}`;+ }++ return JSON.stringify({ embeds: [embed] });+ }}diff --git a/backend/src/notifications/templates/email/backup/ReplicationFailedNotification.ts b/backend/src/notifications/templates/email/backup/ReplicationFailedNotification.tsindex ab483e3..696d8e2 100644--- a/backend/src/notifications/templates/email/backup/ReplicationFailedNotification.ts+++ b/backend/src/notifications/templates/email/backup/ReplicationFailedNotification.ts@@ -16,7 +16,7 @@ export interface ReplicationFailedNotificationPayload {endTime: Date;error: string;failedMirrors?: { storageName: string; error?: string }[];- output?: 'html' | 'json' | 'push';+ output?: 'html' | 'json' | 'push' | 'slack' | 'discord';}export class ReplicationFailedNotification extends BaseNotification {@@ -31,6 +31,12 @@ export class ReplicationFailedNotification extends BaseNotification {if (this.contentType === 'json') {return this.buildJSONContent(data);}+ if (this.contentType === 'slack') {+ return this.buildSlackContent(data);+ }+ if (this.contentType === 'discord') {+ return this.buildDiscordContent(data);+ }return this.buildHTMLContent(data);}@@ -101,4 +107,116 @@ export class ReplicationFailedNotification extends BaseNotification {className: 'content--error',});}++ protected buildSlackContent(data: ReplicationFailedNotificationPayload): string {+ const {+ appTitle,+ deviceName,+ storageName,+ storageType,+ plan,+ error,+ failedMirrors,+ startTime,+ } = data;+ const storageTypeName = storageType ? providers[storageType]?.name || storageType : '';+ const appUrl = configService.config.APP_URL || '';++ const fields: { type: string; text: string }[] = [+ { type: 'mrkdwn', text: `*Plan:* ${plan.title}` },+ { type: 'mrkdwn', text: `*Device:* ${deviceName}` },+ { type: 'mrkdwn', text: `*Storage:* ${storageName} (${storageTypeName})` },+ ];++ const blocks: Record<string, any>[] = [+ {+ type: 'header',+ text: { type: 'plain_text', text: `⚠️ Replication Failed: ${plan.title}`, emoji: true },+ },+ {+ type: 'section',+ fields,+ },+ {+ type: 'section',+ text: { type: 'mrkdwn', text: `*Error:*\n\`\`\`${error}\`\`\`` },+ },+ ];++ if (failedMirrors && failedMirrors.length > 0) {+ const mirrorText = failedMirrors+ .map(m => `• ${m.storageName}${m.error ? `: ${m.error}` : ''}`)+ .join('\n');+ blocks.push({+ type: 'section',+ text: { type: 'mrkdwn', text: `*Failed Mirrors:*\n${mirrorText}` },+ });+ }++ if (appUrl) {+ blocks.push({+ type: 'actions',+ elements: [+ {+ type: 'button',+ text: { type: 'plain_text', text: 'View Plan', emoji: true },+ url: `${appUrl}/plan/${plan.id}`,+ },+ ],+ });+ }++ blocks.push({+ type: 'context',+ elements: [{ type: 'mrkdwn', text: `${appTitle} • ${new Date(startTime).toLocaleString()}` }],+ });++ return JSON.stringify({ blocks });+ }++ protected buildDiscordContent(data: ReplicationFailedNotificationPayload): string {+ const {+ appTitle,+ deviceName,+ storageName,+ storageType,+ plan,+ error,+ failedMirrors,+ startTime,+ } = data;+ const storageTypeName = storageType ? providers[storageType]?.name || storageType : '';+ const appUrl = configService.config.APP_URL || '';++ const fields: { name: string; value: string; inline: boolean }[] = [+ { name: 'Plan', value: plan.title, inline: true },+ { name: 'Device', value: deviceName, inline: true },+ { name: 'Storage', value: `${storageName} (${storageTypeName})`, inline: true },+ { name: 'Error', value: `\`\`\`${error}\`\`\``, inline: false },+ ];++ if (failedMirrors && failedMirrors.length > 0) {+ fields.push({+ name: 'Failed Mirrors',+ value: failedMirrors+ .map(m => `• ${m.storageName}${m.error ? `: ${m.error}` : ''}`)+ .join('\n'),+ inline: false,+ });+ }++ const embed: Record<string, any> = {+ title: `⚠️ Replication Failed: ${plan.title}`,+ color: 0xf59e0b, // amber+ fields,+ timestamp: new Date(startTime).toISOString(),+ footer: { text: appTitle },+ };++ if (appUrl) {+ embed.url = `${appUrl}/plan/${plan.id}`;+ }++ return JSON.stringify({ embeds: [embed] });+ }}diff --git a/backend/src/routes/plans.ts b/backend/src/routes/plans.tsindex d06fea2..1c90706 100644--- a/backend/src/routes/plans.ts+++ b/backend/src/routes/plans.ts@@ -22,6 +22,11 @@ export function createPlanRouter(controller: PlanController, router: Router = RoauthM,controller.deleteReplicationStorage.bind(controller));+ router.post(+ '/:id/action/test-notification',+ authM,+ controller.sendTestBackupNotification.bind(controller)+ );return router;}diff --git a/backend/src/services/PlanService.ts b/backend/src/services/PlanService.tsindex d5d476c..2788da0 100644--- a/backend/src/services/PlanService.ts+++ b/backend/src/services/PlanService.ts@@ -6,7 +6,13 @@ import { BackupStore } from '../stores/BackupStore';import { StorageStore } from '../stores/StorageStore';import { RestoreStore } from '../stores/RestoreStore';import { Plan, NewPlan, planInsertSchema, planUpdateSchema } from '../db/schema/plans';-import { BackupPlanArgs, NewPlanReq, PlanLogItem } from '../types/plans';+import {+ BackupPlanArgs,+ NewPlanReq,+ PlanLogItem,+ PlanNotification,+ PlanNotificationType,+} from '../types/plans';import { planLogger } from '../utils/logger';import { generateUID } from '../utils/helpers';import { intervalToCron } from '../utils/intervalToCron';@@ -18,6 +24,7 @@ import { appPaths } from '../utils/AppPaths';import { AppError, NotFoundError } from '../utils/AppError';import { SourceTypes } from '../types/source';import { sanitizeStoragePath } from '../utils/sanitizeStoragePath';+import { BackupNotification } from '../notifications/BackupNotification';/*** PlanService is the central orchestrator for all business logic related to backup plans.@@ -561,6 +568,71 @@ export class PlanService {}}+ async sendTestNotification(+ planId: string,+ notificationChannel: 'slack' | 'discord' | 'webhook',+ notificationCase: PlanNotificationType,+ channelSettings:+ | PlanNotification['webhook']+ | PlanNotification['slack']+ | PlanNotification['discord']+ ): Promise<void> {+ try {+ const theCase = notificationCase;+ const plan = await this.planStore.getById(planId);+ if (!plan) throw new NotFoundError(`Plan with ID ${planId} not found.`);++ // TODO: for sync backup type this should be different.+ const dummyStats = {+ message_type: 'summary',+ files_new: 2,+ files_changed: 3,+ files_unmodified: 273,+ dirs_new: 0,+ dirs_changed: 0,+ dirs_unmodified: 24,+ data_blobs: 0,+ tree_blobs: 0,+ data_added: 0,+ data_added_packed: 0,+ total_files_processed: 273,+ total_bytes_processed: 2896809876,+ total_duration: 200,+ snapshot_id: '86dajhg985edioguo23782x',+ dry_run: false,+ };++ const payload: Record<string, any> = {+ id: 'edioguo23782y',+ startTime: new Date(),+ stats: dummyStats,+ };+ if (theCase === 'end' || theCase === 'success' || theCase === 'failure') {+ payload.endTime = new Date();+ }+ if (theCase === 'failure') {+ payload.error = 'An Unknown error caused the backup to fail.';+ }++ const planNotifications: PlanNotification | Record<string, any> =+ plan?.settings?.notification || {};+ if (notificationChannel === 'slack') {+ planNotifications.slack = channelSettings as PlanNotification['slack'];+ await new BackupNotification().sendSlack(plan, theCase, payload, theCase);+ } else if (notificationChannel === 'discord') {+ planNotifications.discord = channelSettings as PlanNotification['discord'];+ await new BackupNotification().sendDiscord(plan, theCase, payload, theCase);+ } else {+ throw new AppError(400, 'Invalid notification channel specified.');+ }+ } catch (error) {+ throw new AppError(+ 401,+ `Test webhook request failed. Reason: ${error instanceof Error ? error.message : 'Unknown'}`+ );+ }+ }+private async getStorageDetails(storageId: string): Promise<BackupPlanArgs['storage']> {const storage = await this.storageStore.getById(storageId);if (!storage) {diff --git a/backend/src/types/plans.ts b/backend/src/types/plans.tsindex 54d276a..eebcfa8 100644--- a/backend/src/types/plans.ts+++ b/backend/src/types/plans.ts@@ -17,6 +17,7 @@ export type PlanPrune = {};export type PlanNotificationCase = 'start' | 'end' | 'success' | 'failure' | 'both';+export type PlanNotificationType = 'start' | 'end' | 'success' | 'failure' | 'replication_failure';export type PlanNotification = {email: {@@ -40,6 +41,16 @@ export type PlanNotification = {authToken: string;tags: string;};+ slack: {+ enabled: boolean;+ case: PlanNotificationCase;+ url: string;+ };+ discord: {+ enabled: boolean;+ case: PlanNotificationCase;+ url: string;+ };};export type PlanInterval = {@@ -59,26 +70,7 @@ export type PlanIntegritySettings = {enabled: boolean;interval: PlanInterval; // in daysmethod: string; //full, no-read, read-10%,- notification: {- email: {- enabled: boolean;- type: IntegrationTypes;- emails: string;- };- webhook: {- enabled: boolean;- method: 'GET' | 'POST';- contentType: 'application/json' | 'application/x-www-form-urlencoded' | 'text/plain';- url: string;- };- push: {- enabled: boolean;- url: string;- authType: string;- authToken: string;- tags: string;- };- };+ notification: PlanNotification;};export type BackupVerifiedResult = {diff --git a/frontend/src/@types/plans.ts b/frontend/src/@types/plans.tsindex 3ae76d7..58cbf2b 100644--- a/frontend/src/@types/plans.ts+++ b/frontend/src/@types/plans.ts@@ -36,6 +36,16 @@ export type PlanNotification = {authToken: string;tags: string;};+ slack: {+ enabled: boolean;+ case: PlanNotificationCase;+ url: string;+ };+ discord: {+ enabled: boolean;+ case: PlanNotificationCase;+ url: string;+ };};export type PlanInterval = {@@ -96,26 +106,7 @@ export type PlanIntegritySettings = {enabled: boolean;interval: PlanInterval; // in daysmethod: string; //full, no-read, read-10%,- notification: {- email: {- enabled: boolean;- type: string;- emails: string;- };- webhook: {- enabled: boolean;- method: 'GET' | 'POST';- contentType: 'application/json' | 'application/x-www-form-urlencoded' | 'text/plain';- url: string;- };- push: {- enabled: boolean;- url: string;- authType: string;- authToken: string;- tags: string;- };- };+ notification: PlanNotification;};export type PlanScript = {diff --git a/frontend/src/components/Plan/PlanSettings/PlanAdvancedSettings.tsx b/frontend/src/components/Plan/PlanSettings/PlanAdvancedSettings.tsxindex 256a9ce..c0177f9 100644--- a/frontend/src/components/Plan/PlanSettings/PlanAdvancedSettings.tsx+++ b/frontend/src/components/Plan/PlanSettings/PlanAdvancedSettings.tsx@@ -80,11 +80,11 @@ const PlanAdvancedSettings = ({ plan, appSettings, device, onUpdate }: PlanAdvan{advancedTab === 'Notification' && (<PlanNotificationSettingstypes={integrationTypes}- plan={plan}+ planID={plan.id}+ isSync={plan.method === 'sync'}admin_email={appSettings?.admin_email}- onUpdate={(notification: NewPlanSettings['settings']['notification']) =>- onUpdate({ ...plan, settings: { ...settings, notification } })- }+ notificationSettings={plan.settings?.notification || {}}+ onUpdate={(notification) => onUpdate({ ...plan, settings: { ...settings, notification } })}/>)}{/* {advancedTab === 'Prune' && (diff --git a/frontend/src/components/Plan/PlanSettings/PlanNotificationSettings.tsx b/frontend/src/components/Plan/PlanSettings/PlanNotificationSettings.tsxindex dfafbb6..abadc18 100644--- a/frontend/src/components/Plan/PlanSettings/PlanNotificationSettings.tsx+++ b/frontend/src/components/Plan/PlanSettings/PlanNotificationSettings.tsx@@ -2,75 +2,207 @@ import classes from './PlanSettings.module.scss';import Select from '../../common/form/Select/Select';import Input from '../../common/form/Input/Input';import Toggle from '../../common/form/Toggle/Toggle';-import { NewPlanSettings, PlanNotificationCase } from '../../../@types/plans';+import { PlanNotification, PlanNotificationCase } from '../../../@types/plans';import { NavLink } from 'react-router';+import PlanNotificationSettingsTester from './PlanNotificationSettingsTester';+import { Icon } from '../..';interface PlanNotificationSettingsProps {- plan: NewPlanSettings;types: string[];+ isSync: boolean;+ notificationType?: 'backup' | 'integrity';admin_email?: string;- onUpdate: (notificationSettings: NewPlanSettings['settings']['notification']) => void;+ planID?: string;+ notificationSettings: PlanNotification;+ onUpdate: (notificationSettings: PlanNotification) => void;}-const PlanNotificationSettings = ({ plan, types = [], admin_email = '', onUpdate }: PlanNotificationSettingsProps) => {- const notificationSettings = plan.settings?.notification || {};+const PlanNotificationSettings = ({+ planID,+ isSync,+ types = [],+ admin_email = '',+ notificationSettings,+ notificationType = 'backup',+ onUpdate,+}: PlanNotificationSettingsProps) => {+ const hasConnectedIntegrations = types.length > 0;+ const defaultEmail = !hasConnectedIntegrations && admin_email ? admin_email : '';const updateNotificationEmails = (emails: string) => {onUpdate({ ...notificationSettings, email: { ...notificationSettings.email, emails } });};- const hasConnectedIntegrations = types.length > 0;- const defaultEmail = !hasConnectedIntegrations && admin_email ? admin_email : '';+ const caseOptions = [+ { label: 'On Start', value: 'start' },+ { label: 'On End', value: 'end' },+ { label: 'On Both Start & End', value: 'both' },+ { label: 'On Success Only', value: 'success' },+ { label: 'On Failure Only', value: 'failure' },+ ];return (<>- <div className={classes.field}>- <label className={classes.label}>Notification</label>- <Toggle- fieldValue={notificationSettings?.email?.enabled || false}- onUpdate={(val: boolean) => onUpdate({ ...notificationSettings, email: { ...notificationSettings.email, enabled: val } })}- description={plan.method === 'sync' ? 'Notify Me when Sync fails' : 'Notify Me when Backup fails or succeeds'}- />+ <div className={classes.notificationSettingsSection}>+ <div className={`${classes.field} ${classes.notificationToggle}`}>+ <Icon type="email" size={14} />+ <Toggle+ label="Enable Email Notifications"+ fieldValue={notificationSettings?.email?.enabled || false}+ onUpdate={(val: boolean) => onUpdate({ ...notificationSettings, email: { ...notificationSettings.email, enabled: val } })}+ hint={'Notify me via email when Backup fails or succeeds'}+ inline={true}+ />+ </div>+ {notificationSettings?.email?.enabled && (+ <div className={classes.notificationSettings}>+ {!isSync && (+ <div className={classes.field}>+ <Select+ label="Send Notification"+ fieldValue={notificationSettings?.email?.case || 'failure'}+ options={caseOptions}+ onUpdate={(val: string) =>+ onUpdate({ ...notificationSettings, email: { ...notificationSettings.email, case: val as PlanNotificationCase } })+ }+ inline={true}+ />+ </div>+ )}+ <div className={classes.field}>+ <Input+ label="Email Addresses"+ fieldValue={notificationSettings?.email?.emails || defaultEmail}+ onUpdate={(val) => updateNotificationEmails(val)}+ placeholder="[email protected], [email protected]"+ full={true}+ inline={true}+ required={true}+ disabled={!hasConnectedIntegrations}+ error={!notificationSettings?.email?.emails ? 'Required' : undefined}+ />+ {!hasConnectedIntegrations && (+ <div className={classes.fieldNotice}>+ ⚠️ SMTP has not been setup yet. Set it up in <NavLink to={`/settings?t=integration`}>Settings</NavLink> to enable Email+ Notification.+ </div>+ )}+ </div>+ </div>+ )}</div>- {notificationSettings?.email?.enabled && (- <>- {plan.method !== 'sync' && (++ {/* Slack Notification */}+ <div className={classes.notificationSettingsSection}>+ <div className={`${classes.field} ${classes.notificationToggle}`}>+ <Icon type="slack" size={14} />+ <Toggle+ label="Enable Slack Notifications"+ fieldValue={notificationSettings?.slack?.enabled || false}+ onUpdate={(val: boolean) =>+ onUpdate({+ ...notificationSettings,+ slack: { ...notificationSettings.slack, enabled: val, url: notificationSettings.slack?.url || '' },+ })+ }+ hint="Send notifications to a Slack channel via webhook"+ inline={true}+ />+ </div>+ {notificationSettings?.slack?.enabled && (+ <div className={classes.notificationSettings}>+ {!isSync && (+ <div className={classes.field}>+ <Select+ label="Send Slack Notification"+ fieldValue={notificationSettings?.slack?.case || 'failure'}+ options={caseOptions}+ onUpdate={(val: string) =>+ onUpdate({ ...notificationSettings, slack: { ...notificationSettings.slack, case: val as PlanNotificationCase } })+ }+ inline={true}+ />+ </div>+ )}<div className={classes.field}>- <label className={classes.label}>Send Notification</label>- <Select- fieldValue={notificationSettings?.email?.case || 'failure'}- options={[- { label: 'On Start', value: 'start' },- { label: 'On End', value: 'end' },- { label: 'On Both Start & End', value: 'both' },- { label: 'On Success Only', value: 'success' },- { label: 'On Failure Only', value: 'failure' },- ]}- onUpdate={(val: string) =>- onUpdate({ ...notificationSettings, email: { ...notificationSettings.email, case: val as PlanNotificationCase } })- }+ <Input+ label="Slack Webhook URL"+ fieldValue={notificationSettings?.slack?.url || ''}+ onUpdate={(val) => onUpdate({ ...notificationSettings, slack: { ...notificationSettings.slack, url: val } })}+ placeholder="https://hooks.slack.com/services/T00/B00/xxxx"+ required={true}+ inline={true}+ full={true}+ error={notificationSettings?.slack?.enabled && !notificationSettings?.slack?.url ? 'Required' : undefined}+ />+ </div>+ <div className={`${classes.field} ${classes.notificationTestField}`}>+ <PlanNotificationSettingsTester+ planId={planID || ''}+ notificationChannel="slack"+ notificationSettings={notificationSettings}+ notificationType={notificationType}/></div>- )}- <div className={classes.field}>- <label className={classes.label}>Email Addresses</label>- <Input- fieldValue={notificationSettings?.email?.emails || defaultEmail}- onUpdate={(val) => updateNotificationEmails(val)}- placeholder="[email protected], [email protected]"- full={true}- disabled={!hasConnectedIntegrations}- error={!notificationSettings?.email?.emails ? 'Required' : undefined}- />- {!hasConnectedIntegrations && (- <div className={classes.fieldNotice}>- ⚠️ SMTP has not been setup yet. Set it up in <NavLink to={`/settings?t=integration`}>Settings</NavLink> to enable Email- Notification.+ </div>+ )}+ </div>++ {/* Discord Notification */}+ <div className={classes.notificationSettingsSection}>+ <div className={`${classes.field} ${classes.notificationToggle}`}>+ <Icon type="discord" size={14} />+ <Toggle+ label="Send Discord Notifications"+ fieldValue={notificationSettings?.discord?.enabled || false}+ onUpdate={(val: boolean) =>+ onUpdate({+ ...notificationSettings,+ discord: { ...notificationSettings.discord, enabled: val, url: notificationSettings.discord?.url || '' },+ })+ }+ hint="Send notifications to a Discord channel via webhook"+ inline={true}+ />+ </div>+ {notificationSettings?.discord?.enabled && (+ <div className={classes.notificationSettings}>+ {!isSync && (+ <div className={classes.field}>+ <Select+ label="Send Discord Notification"+ fieldValue={notificationSettings?.discord?.case || 'failure'}+ options={caseOptions}+ onUpdate={(val: string) =>+ onUpdate({ ...notificationSettings, discord: { ...notificationSettings.discord, case: val as PlanNotificationCase } })+ }+ inline={true}+ /></div>)}+ <div className={classes.field}>+ <Input+ label="Discord Webhook URL"+ fieldValue={notificationSettings?.discord?.url || ''}+ onUpdate={(val) => onUpdate({ ...notificationSettings, discord: { ...notificationSettings.discord, url: val } })}+ placeholder="https://discord.com/api/webhooks/xxxx/xxxx"+ required={true}+ inline={true}+ full={true}+ error={notificationSettings?.discord?.enabled && !notificationSettings?.discord?.url ? 'Required' : undefined}+ />+ </div>+ <div className={`${classes.field} ${classes.notificationTestField}`}>+ <PlanNotificationSettingsTester+ planId={planID || ''}+ notificationChannel="discord"+ notificationType={notificationType}+ notificationSettings={notificationSettings}+ />+ </div></div>- </>- )}+ )}+ </div></>);};diff --git a/frontend/src/components/Plan/PlanSettings/PlanNotificationSettingsTester.tsx b/frontend/src/components/Plan/PlanSettings/PlanNotificationSettingsTester.tsxnew file mode 100644index 0000000..c2b9a92--- /dev/null+++ b/frontend/src/components/Plan/PlanSettings/PlanNotificationSettingsTester.tsx@@ -0,0 +1,85 @@+import { toast } from 'react-toastify';+import { useState } from 'react';+import { useTestNotification } from '../../../services';+import { Icon } from '../..';+import { NewPlanSettings, PlanNotificationCase } from '../../..';+import classes from './PlanSettings.module.scss';+import { isValidURL } from '../../../utils';++const PlanNotificationSettingsTester = ({+ planId,+ notificationChannel,+ notificationSettings,+ notificationType = 'backup',+}: {+ planId: string;+ notificationType?: 'backup' | 'integrity';+ notificationChannel: 'webhook' | 'slack' | 'discord';+ notificationSettings: NewPlanSettings['settings']['notification'];+}) => {+ const [showTestNotificationOptions, setShowTestNotificationOptions] = useState(false);+ const testNotificationMutation = useTestNotification();+ const channelSettings = notificationSettings[notificationChannel as 'webhook' | 'slack' | 'discord'];+ const integrityNotification = notificationType === 'integrity';++ const sendTestNotification = (notificationCase: PlanNotificationCase | 'integrity_failure') => {+ setShowTestNotificationOptions(false);+ if (!planId) {+ return toast.error('Test notification can be sent after creating the Plan');+ }+ if (!channelSettings?.url || !isValidURL(channelSettings.url)) {+ return toast.error(`Please enter a valid URL to send test notifications`);+ }++ toast.promise(+ testNotificationMutation.mutateAsync({+ planId,+ notificationCase: notificationCase,+ notificationChannel,+ channelSettings: channelSettings,+ }),+ {+ pending: `Sending Test Request to your ${notificationChannel}...`,+ success: 'Test Request Sent Successfully!',+ error: {+ render({ data }: any) {+ return data.message || 'Failed to send test request';+ },+ },+ },+ );+ };++ return (+ <div className={classes.testNotificationContainer}>+ <button+ onClick={() =>+ integrityNotification ? sendTestNotification('integrity_failure') : setShowTestNotificationOptions(!showTestNotificationOptions)+ }+ className={`${classes.testNotificationButton} ${!channelSettings?.url ? classes.disabled : ''}`}+ disabled={!channelSettings?.url || !planId}+ title={+ !planId+ ? 'Create the Plan first to send test notifications'+ : !channelSettings?.url+ ? `Enter ${notificationChannel === 'webhook' ? 'the' : notificationChannel.charAt(0).toUpperCase() + notificationChannel.slice(1)} Webhook URL to send test notifications`+ : undefined+ }+ >+ <Icon type="send" size={12} /> Send Test Request+ </button>+ {!integrityNotification && showTestNotificationOptions && (+ <div className={classes.testNotificationOptions}>+ <ul>+ <li onClick={() => sendTestNotification('start')}>Start Notification</li>+ <li onClick={() => sendTestNotification('end')}>End Notification</li>+ <li onClick={() => sendTestNotification('success')}>Success Notification</li>+ <li onClick={() => sendTestNotification('failure')}>Failure Notification</li>+ </ul>+ </div>+ )}+ </div>+ );+};++export default PlanNotificationSettingsTester;diff --git a/frontend/src/components/Plan/PlanSettings/PlanSettings.module.scss b/frontend/src/components/Plan/PlanSettings/PlanSettings.module.scssindex b2d38ae..42a6882 100644--- a/frontend/src/components/Plan/PlanSettings/PlanSettings.module.scss+++ b/frontend/src/components/Plan/PlanSettings/PlanSettings.module.scss@@ -462,3 +462,74 @@}}}++.notificationTestField {+ display: flex;+ justify-content: right;+ margin-bottom: 0;+}++.notificationSettingsSection {+ border-radius: 6px;+ border: 1px solid var(--line-color);+ margin-bottom: 15px;+ .notificationToggle {+ margin-bottom: 0;+ padding: 10px;+ box-sizing: border-box;+ display: flex;+ align-items: center;+ gap: 5px;+ div[class*='_fieldInner'] {+ justify-content: space-between;+ }+ }+ .notificationSettings {+ padding: 15px;+ border-top: 1px solid var(--line-color);+ }+}++.testNotificationContainer {+ display: inline-block;+ position: relative;+ .testNotificationButton {+ padding: 6px 12px;+ background-color: var(--primary-color-light);+ color: var(--primary-color);+ font-weight: 600;+ font-size: 0.9em;+ border-radius: 4px;+ cursor: pointer;+ &.disabled {+ cursor: not-allowed;+ opacity: 0.6;+ }+ }++ .testNotificationOptions {+ position: absolute;+ width: 140px;+ background-color: var(--content-background-color);+ border-radius: 6px;+ border: 1px solid var(--primary-color-mid);+ bottom: 30px;+ right: 0px;+ z-index: 9;+ ul {+ list-style-type: none;+ margin: 0;+ padding: 0;+ li {+ font-size: 0.9em;+ cursor: pointer;+ padding: 6px 12px;++ &:hover {+ background-color: var(--primary-color-light);+ color: var(--primary-color);+ }+ }+ }+ }+}diff --git a/frontend/src/components/common/Icon/Icon.tsx b/frontend/src/components/common/Icon/Icon.tsxindex 82b0cc0..b41a686 100644--- a/frontend/src/components/common/Icon/Icon.tsx+++ b/frontend/src/components/common/Icon/Icon.tsx@@ -1507,6 +1507,22 @@ const Icon = ({ type, color = 'currentColor', size = 16, title = '', classes = '></path></IconWrapper>)}+ {type === 'discord' && (+ <IconWrapper size={size} viewBox="0 0 256 199">+ <path+ fill="#5865f2"+ d="M216.856 16.597A208.5 208.5 0 0 0 164.042 0c-2.275 4.113-4.933 9.645-6.766 14.046q-29.538-4.442-58.533 0c-1.832-4.4-4.55-9.933-6.846-14.046a207.8 207.8 0 0 0-52.855 16.638C5.618 67.147-3.443 116.4 1.087 164.956c22.169 16.555 43.653 26.612 64.775 33.193A161 161 0 0 0 79.735 175.3a136.4 136.4 0 0 1-21.846-10.632a109 109 0 0 0 5.356-4.237c42.122 19.702 87.89 19.702 129.51 0a132 132 0 0 0 5.355 4.237a136 136 0 0 1-21.886 10.653c4.006 8.02 8.638 15.67 13.873 22.848c21.142-6.58 42.646-16.637 64.815-33.213c5.316-56.288-9.08-105.09-38.056-148.36M85.474 135.095c-12.645 0-23.015-11.805-23.015-26.18s10.149-26.2 23.015-26.2s23.236 11.804 23.015 26.2c.02 14.375-10.148 26.18-23.015 26.18m85.051 0c-12.645 0-23.014-11.805-23.014-26.18s10.148-26.2 23.014-26.2c12.867 0 23.236 11.804 23.015 26.2c0 14.375-10.148 26.18-23.015 26.18"+ />+ </IconWrapper>+ )}+ {type === 'webhook' && (+ <IconWrapper size={size} viewBox="0 0 24 24">+ <path+ fill={color}+ d="M7 21q-2.075 0-3.537-1.463T2 16q0-1.4.675-2.537t1.8-1.788q.525-.3 1.025.013t.5.862q0 .275-.112.5t-.313.325q-.7.375-1.137 1.075T4 16q0 1.25.875 2.125T7 19t2.125-.875T10 16q0-.425.238-.712T10.9 15h4.975q.2-.225.488-.363T17 14.5q.625 0 1.063.438T18.5 16t-.437 1.063T17 17.5q-.35 0-.638-.137T15.876 17H11.9q-.35 1.725-1.713 2.863T7 21m0-3.5q-.625 0-1.062-.437T5.5 16q0-.55.35-.95t.85-.525l2.35-3.9q-.725-.675-1.138-1.612T7.5 7q0-2.075 1.463-3.537T12.5 2q1.75 0 3.088 1.063T17.35 5.75q.125.475-.175.863t-.8.387q-.325 0-.612-.238t-.388-.587q-.275-.95-1.05-1.562T12.5 4q-1.25 0-2.125.875T9.5 7q0 .825.413 1.513T10.974 9.6q.35.2.438.5t-.088.6l-2.9 4.85q.05.125.063.225T8.5 16q0 .625-.437 1.063T7 17.5M17 21q-.65 0-1.263-.162T14.6 20.4q-.675-.375-.537-1.137t1.012-.763q.125 0 .275.05t.275.125q.325.175.663.25T17 19q1.25 0 2.125-.875T20 16t-.875-2.125T17 13q-.25 0-.475.038t-.45.112q-.4.125-.75.013t-.525-.388l-2.575-4.3q-.525-.1-.875-.5T11 7q0-.625.438-1.062T12.5 5.5t1.063.438T14 7v.213q0 .087-.05.212l2.175 3.65q.2-.05.425-.062T17 11q2.075 0 3.538 1.463T22 16t-1.463 3.538T17 21"+ />+ </IconWrapper>+ )}</span>);};diff --git a/frontend/src/components/index.ts b/frontend/src/components/index.tsindex e14e41c..49b2a45 100644--- a/frontend/src/components/index.ts+++ b/frontend/src/components/index.ts@@ -80,6 +80,7 @@ export { default as PlanRemoveModal } from './Plan/PlanRemoveModal/PlanRemoveModexport { default as PlanAdvancedSettings } from './Plan/PlanSettings/PlanAdvancedSettings';export { default as PlanGeneralSettings } from './Plan/PlanSettings/PlanGeneralSettings';export { default as PlanNotificationSettings } from './Plan/PlanSettings/PlanNotificationSettings';+export { default as PlanNotificationSettingsTester } from './Plan/PlanSettings/PlanNotificationSettingsTester';export { default as PlanPerformanceSettings } from './Plan/PlanSettings/PlanPerformanceSettings';export { default as PlanPruneSettings } from './Plan/PlanSettings/PlanPruneSettings';export { default as PlanScriptsSettings } from './Plan/PlanSettings/PlanScriptsSettings';diff --git a/frontend/src/services/plans.ts b/frontend/src/services/plans.tsindex 8b45013..f4d7d68 100644--- a/frontend/src/services/plans.ts+++ b/frontend/src/services/plans.ts@@ -1,7 +1,7 @@import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';import { toast } from 'react-toastify';import { API_URL } from '../utils/constants';-import { NewPlanSettings, Plan } from '../@types/plans';+import { NewPlanSettings, Plan, PlanNotification } from '../@types/plans';// Get All Plansexport async function getAllPlans() {@@ -467,3 +467,40 @@ export function useCheckPlanIntegrity() {},});}++export async function sendTestNotificationRequest(payload: {+ planId: string;+ notificationCase: string;+ notificationChannel: 'webhook' | 'slack' | 'discord';+ channelSettings: PlanNotification['webhook'] | PlanNotification['slack'] | PlanNotification['discord'];+}) {+ console.log('payload :', payload);+ const headers = new Headers({ 'Content-Type': 'application/json', Accept: 'application/json' });+ const res = await fetch(`${API_URL}/plans/${payload.planId}/action/test-notification`, {+ method: 'POST',+ headers,+ credentials: 'include',+ body: JSON.stringify(payload),+ });++ // Check if response is ok+ if (!res.ok) {+ const data = await res.json();+ throw new Error(data.error);+ }++ const data = await res.json();+ return data;+}++export function useTestNotification() {+ return useMutation({+ mutationFn: sendTestNotificationRequest,+ onSuccess: (res) => {+ console.log('# Test notification request sent successfully! :', res);+ },+ onError: (res) => {+ console.log('# Test notification request failed! :', res);+ },+ });+}diff --git a/frontend/src/utils/constants.ts b/frontend/src/utils/constants.tsindex 147a303..f376e0d 100644--- a/frontend/src/utils/constants.ts+++ b/frontend/src/utils/constants.ts@@ -42,6 +42,16 @@ export const DEFAULT_PLAN_SETTINGS: NewPlanSettings = {authToken: '',tags: '',},+ slack: {+ enabled: false,+ case: 'failure',+ url: '',+ },+ discord: {+ enabled: false,+ case: 'failure',+ url: '',+ },},prune: {snapCount: 5,@@ -61,12 +71,14 @@ export const DEFAULT_PLAN_SETTINGS: NewPlanSettings = {enabled: false,type: 'smtp',emails: '',+ case: 'failure',},webhook: {enabled: false,method: 'POST',contentType: 'application/json',url: '',+ case: 'failure',},push: {enabled: false,@@ -74,6 +86,17 @@ export const DEFAULT_PLAN_SETTINGS: NewPlanSettings = {authType: 'none',authToken: '',tags: '',+ case: 'failure',+ },+ slack: {+ enabled: false,+ case: 'failure',+ url: '',+ },+ discord: {+ enabled: false,+ case: 'failure',+ url: '',},},},diff --git a/frontend/src/utils/helpers.ts b/frontend/src/utils/helpers.tsindex 3878000..938d4d8 100644--- a/frontend/src/utils/helpers.ts+++ b/frontend/src/utils/helpers.ts@@ -343,6 +343,15 @@ export const isValidEmail = (email: string): boolean => {return true;};+export const isValidURL = (url: string): boolean => {+ try {+ new URL(url);+ return true;+ } catch {+ return false;+ }+};+export const shouldDisplayStorageField = (field: storageOptionField, settings: Record<string, any>, allFields: storageOptionField[]): boolean => {// If no conditions, always display the fieldif (!field.condition || field.condition.length === 0) {diff --git a/frontend/tsconfig.json b/frontend/tsconfig.jsonindex cbcab6f..b99b116 100644--- a/frontend/tsconfig.json+++ b/frontend/tsconfig.json@@ -11,6 +11,7 @@"paths": {"@/*": ["./src/*"]},- "target": "esnext"+ "target": "esnext",+ "ignoreDeprecations": "6.0"}}