From 6aa7c8a3d8734b55f932e8c270d830bc8644d36f Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Thu, 5 Jun 2025 13:34:18 +0200 Subject: [PATCH 1/5] added notification --- server/managers/NotificationManager.js | 48 ++++++++++++++++++++++++++ server/managers/PodcastManager.js | 2 ++ server/utils/notifications.js | 32 +++++++++++++++++ 3 files changed, 82 insertions(+) diff --git a/server/managers/NotificationManager.js b/server/managers/NotificationManager.js index 8edcf428..4f7072be 100644 --- a/server/managers/NotificationManager.js +++ b/server/managers/NotificationManager.js @@ -71,6 +71,54 @@ class NotificationManager { this.triggerNotification('onBackupCompleted', eventData) } + /** + * Handles RSS feed updates + * @param feedUrl + * @param numFailed + * @param title + * @returns {Promise} + */ + async onRSSFeedFailed(feedUrl, numFailed, title) { + if (!Database.notificationSettings.isUseable) return + + if (!Database.notificationSettings.getHasActiveNotificationsForEvent('onRSSFeedFailed')) { + Logger.debug(`[NotificationManager] onRSSFeedFailed: No active notifications`) + return + } + + Logger.debug(`[NotificationManager] onRSSFeedFailed: RSS feed update failed for ${feedUrl}`) + const eventData = { + feedUrl: feedUrl, + numFailed: numFailed || 0, + title: title || 'Unknown Title' + } + this.triggerNotification('onRSSFeedFailed', eventData) + } + + /** + * Handles RSS feed being disabled due to too many failed updates + * @param feedUrl + * @param numFailed + * @param title + * @returns {Promise} + */ + async onRSSFeedDisabled(feedUrl, numFailed, title) { + if (!Database.notificationSettings.isUseable) return + + if (!Database.notificationSettings.getHasActiveNotificationsForEvent('onRSSFeedDisabled')) { + Logger.debug(`[NotificationManager] onRSSFeedDisabled: No active notifications`) + return + } + + Logger.debug(`[NotificationManager] onRSSFeedDisabled: RSS feed disabled due to ${numFailed} failed updates for ${feedUrl}`) + const eventData = { + feedUrl: feedUrl, + numFailed: numFailed || 0, + title: title || 'Unknown Title' + } + this.triggerNotification('onRSSFeedDisabled', eventData) + } + /** * * @param {string} errorMsg diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index 625688c9..e5da8fe6 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -347,10 +347,12 @@ class PodcastManager { this.failedCheckMap[libraryItem.id]++ if (this.failedCheckMap[libraryItem.id] >= this.MaxFailedEpisodeChecks) { Logger.error(`[PodcastManager] runEpisodeCheck ${this.failedCheckMap[libraryItem.id]} failed attempts at checking episodes for "${libraryItem.media.title}" - disabling auto download`) + void NotificationManager.onRSSFeedDisabled(libraryItem.media.feedURL, this.failedCheckMap[libraryItem.id], libraryItem.media.title) libraryItem.media.autoDownloadEpisodes = false delete this.failedCheckMap[libraryItem.id] } else { Logger.warn(`[PodcastManager] runEpisodeCheck ${this.failedCheckMap[libraryItem.id]} failed attempts at checking episodes for "${libraryItem.media.title}"`) + void NotificationManager.onRSSFeedFailed(libraryItem.media.feedURL, this.failedCheckMap[libraryItem.id], libraryItem.media.title) } } else if (newEpisodes.length) { delete this.failedCheckMap[libraryItem.id] diff --git a/server/utils/notifications.js b/server/utils/notifications.js index 7a3e1198..1b9612b9 100644 --- a/server/utils/notifications.js +++ b/server/utils/notifications.js @@ -60,6 +60,38 @@ module.exports.notificationData = { errorMsg: 'Example error message' } }, + { + name: 'onRSSFeedFailed', + requiresLibrary: true, + description: 'Triggered when an RSS feed request/update fails, but gets not disabled', + descriptionKey: 'NotificationOnRSSFeedFailedDescription', + variables: ['feedUrl', 'numFailed', 'title'], + defaults: { + title: 'RSS Feed Update Failed', + body: 'Failed to update RSS feed for {{title}}.\nFeed URL: {{feedUrl}}\nNumber of failed attempts: {{numFailed}}' + }, + testData: { + title: 'Test RSS Feed', + feedUrl: 'https://example.com/rss', + numFailed: 3 + } + }, + { + name: 'onRSSFeedDisabled', + requiresLibrary: true, + description: 'Triggered when an RSS feed is disabled due to too many failed attempts', + descriptionKey: 'NotificationOnRSSFeedDisabledDescription', + variables: ['feedUrl', 'numFailed', 'title'], + defaults: { + title: 'RSS Feed Disabled', + body: 'RSS feed for {{title}} has been disabled due to too many failed updates.\nFeed URL: {{feedUrl}}\nNumber of failed attempts: {{numFailed}}' + }, + testData: { + title: 'Test RSS Feed', + feedUrl: 'https://example.com/rss', + numFailed: 5 + } + }, { name: 'onTest', requiresLibrary: false, From 346df3680ce8dd415ce3d77d5ce789686e8dd5f9 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Thu, 5 Jun 2025 14:02:29 +0200 Subject: [PATCH 2/5] local strings --- client/strings/en-us.json | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 939eb9f4..65fd5f0e 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -918,6 +918,8 @@ "NotificationOnBackupCompletedDescription": "Triggered when a backup is completed", "NotificationOnBackupFailedDescription": "Triggered when a backup fails", "NotificationOnEpisodeDownloadedDescription": "Triggered when a podcast episode is auto-downloaded", + "NotificationOnRSSFeedFailedDescription": "Triggered when an RSS feed request/update fails, but gets not disabled", + "NotificationOnRSSFeedDisabledDescription": "Triggered when an RSS feed is disabled due to too many failed attempts", "NotificationOnTestDescription": "Event for testing the notification system", "PlaceholderNewCollection": "New collection name", "PlaceholderNewFolderPath": "New folder path", From f0525d4f0de8392b87d788fda3a0a6bda57d15c8 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Thu, 5 Jun 2025 14:09:35 +0200 Subject: [PATCH 3/5] abc is hard --- client/strings/en-us.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 65fd5f0e..afecd671 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -918,8 +918,8 @@ "NotificationOnBackupCompletedDescription": "Triggered when a backup is completed", "NotificationOnBackupFailedDescription": "Triggered when a backup fails", "NotificationOnEpisodeDownloadedDescription": "Triggered when a podcast episode is auto-downloaded", - "NotificationOnRSSFeedFailedDescription": "Triggered when an RSS feed request/update fails, but gets not disabled", "NotificationOnRSSFeedDisabledDescription": "Triggered when an RSS feed is disabled due to too many failed attempts", + "NotificationOnRSSFeedFailedDescription": "Triggered when an RSS feed request/update fails, but gets not disabled", "NotificationOnTestDescription": "Event for testing the notification system", "PlaceholderNewCollection": "New collection name", "PlaceholderNewFolderPath": "New folder path", From 7122756e585a2d4213f1af2a347f287d8b6e2473 Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 9 Jun 2025 15:51:14 -0500 Subject: [PATCH 4/5] Update notification description grammar --- client/strings/en-us.json | 2 +- server/utils/notifications.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/strings/en-us.json b/client/strings/en-us.json index afecd671..25c8268b 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -919,7 +919,7 @@ "NotificationOnBackupFailedDescription": "Triggered when a backup fails", "NotificationOnEpisodeDownloadedDescription": "Triggered when a podcast episode is auto-downloaded", "NotificationOnRSSFeedDisabledDescription": "Triggered when an RSS feed is disabled due to too many failed attempts", - "NotificationOnRSSFeedFailedDescription": "Triggered when an RSS feed request/update fails, but gets not disabled", + "NotificationOnRSSFeedFailedDescription": "Triggered when an RSS feed request/update fails, but is not disabled", "NotificationOnTestDescription": "Event for testing the notification system", "PlaceholderNewCollection": "New collection name", "PlaceholderNewFolderPath": "New folder path", diff --git a/server/utils/notifications.js b/server/utils/notifications.js index 1b9612b9..304b4ffe 100644 --- a/server/utils/notifications.js +++ b/server/utils/notifications.js @@ -63,7 +63,7 @@ module.exports.notificationData = { { name: 'onRSSFeedFailed', requiresLibrary: true, - description: 'Triggered when an RSS feed request/update fails, but gets not disabled', + description: 'Triggered when an RSS feed request/update fails, but is not disabled', descriptionKey: 'NotificationOnRSSFeedFailedDescription', variables: ['feedUrl', 'numFailed', 'title'], defaults: { From 5e2bb0b12ccacaca5d231e4a5a3bd9ffb111a9df Mon Sep 17 00:00:00 2001 From: advplyr Date: Mon, 9 Jun 2025 16:21:05 -0500 Subject: [PATCH 5/5] Fix notification js docs and update description/defaults --- client/strings/en-us.json | 4 ++-- server/managers/NotificationManager.js | 24 ++++++++++++------------ server/utils/notifications.js | 12 ++++++------ 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 25c8268b..f6288912 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -918,8 +918,8 @@ "NotificationOnBackupCompletedDescription": "Triggered when a backup is completed", "NotificationOnBackupFailedDescription": "Triggered when a backup fails", "NotificationOnEpisodeDownloadedDescription": "Triggered when a podcast episode is auto-downloaded", - "NotificationOnRSSFeedDisabledDescription": "Triggered when an RSS feed is disabled due to too many failed attempts", - "NotificationOnRSSFeedFailedDescription": "Triggered when an RSS feed request/update fails, but is not disabled", + "NotificationOnRSSFeedDisabledDescription": "Triggered when automatic episode downloads are disabled due to too many failed attempts", + "NotificationOnRSSFeedFailedDescription": "Triggered when the RSS feed request fails for an automatic episode download", "NotificationOnTestDescription": "Event for testing the notification system", "PlaceholderNewCollection": "New collection name", "PlaceholderNewFolderPath": "New folder path", diff --git a/server/managers/NotificationManager.js b/server/managers/NotificationManager.js index 4f7072be..567da38e 100644 --- a/server/managers/NotificationManager.js +++ b/server/managers/NotificationManager.js @@ -72,11 +72,11 @@ class NotificationManager { } /** - * Handles RSS feed updates - * @param feedUrl - * @param numFailed - * @param title - * @returns {Promise} + * Handles scheduled episode download RSS feed request failed + * + * @param {string} feedUrl + * @param {number} numFailed + * @param {string} title */ async onRSSFeedFailed(feedUrl, numFailed, title) { if (!Database.notificationSettings.isUseable) return @@ -86,7 +86,7 @@ class NotificationManager { return } - Logger.debug(`[NotificationManager] onRSSFeedFailed: RSS feed update failed for ${feedUrl}`) + Logger.debug(`[NotificationManager] onRSSFeedFailed: RSS feed request failed for ${feedUrl}`) const eventData = { feedUrl: feedUrl, numFailed: numFailed || 0, @@ -96,11 +96,11 @@ class NotificationManager { } /** - * Handles RSS feed being disabled due to too many failed updates - * @param feedUrl - * @param numFailed - * @param title - * @returns {Promise} + * Handles scheduled episode downloads disabled due to too many failed attempts + * + * @param {string} feedUrl + * @param {number} numFailed + * @param {string} title */ async onRSSFeedDisabled(feedUrl, numFailed, title) { if (!Database.notificationSettings.isUseable) return @@ -110,7 +110,7 @@ class NotificationManager { return } - Logger.debug(`[NotificationManager] onRSSFeedDisabled: RSS feed disabled due to ${numFailed} failed updates for ${feedUrl}`) + Logger.debug(`[NotificationManager] onRSSFeedDisabled: Podcast scheduled episode download disabled due to ${numFailed} failed requests for ${feedUrl}`) const eventData = { feedUrl: feedUrl, numFailed: numFailed || 0, diff --git a/server/utils/notifications.js b/server/utils/notifications.js index 304b4ffe..700d3c38 100644 --- a/server/utils/notifications.js +++ b/server/utils/notifications.js @@ -63,12 +63,12 @@ module.exports.notificationData = { { name: 'onRSSFeedFailed', requiresLibrary: true, - description: 'Triggered when an RSS feed request/update fails, but is not disabled', + description: 'Triggered when the RSS feed request fails for an automatic episode download', descriptionKey: 'NotificationOnRSSFeedFailedDescription', variables: ['feedUrl', 'numFailed', 'title'], defaults: { - title: 'RSS Feed Update Failed', - body: 'Failed to update RSS feed for {{title}}.\nFeed URL: {{feedUrl}}\nNumber of failed attempts: {{numFailed}}' + title: 'RSS Feed Request Failed', + body: 'Failed to request RSS feed for {{title}}.\nFeed URL: {{feedUrl}}\nNumber of failed attempts: {{numFailed}}' }, testData: { title: 'Test RSS Feed', @@ -79,12 +79,12 @@ module.exports.notificationData = { { name: 'onRSSFeedDisabled', requiresLibrary: true, - description: 'Triggered when an RSS feed is disabled due to too many failed attempts', + description: 'Triggered when automatic episode downloads are disabled due to too many failed attempts', descriptionKey: 'NotificationOnRSSFeedDisabledDescription', variables: ['feedUrl', 'numFailed', 'title'], defaults: { - title: 'RSS Feed Disabled', - body: 'RSS feed for {{title}} has been disabled due to too many failed updates.\nFeed URL: {{feedUrl}}\nNumber of failed attempts: {{numFailed}}' + title: 'Podcast Episode Download Schedule Disabled', + body: 'Automatic episode downloads for {{title}} have been disabled due to too many failed RSS feed requests.\nFeed URL: {{feedUrl}}\nNumber of failed attempts: {{numFailed}}' }, testData: { title: 'Test RSS Feed',