mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-20 17:58:01 +02:00
added notification
This commit is contained in:
parent
704c6f7bde
commit
6aa7c8a3d8
@ -71,6 +71,54 @@ class NotificationManager {
|
|||||||
this.triggerNotification('onBackupCompleted', eventData)
|
this.triggerNotification('onBackupCompleted', eventData)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles RSS feed updates
|
||||||
|
* @param feedUrl
|
||||||
|
* @param numFailed
|
||||||
|
* @param title
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
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<void>}
|
||||||
|
*/
|
||||||
|
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
|
* @param {string} errorMsg
|
||||||
|
@ -347,10 +347,12 @@ class PodcastManager {
|
|||||||
this.failedCheckMap[libraryItem.id]++
|
this.failedCheckMap[libraryItem.id]++
|
||||||
if (this.failedCheckMap[libraryItem.id] >= this.MaxFailedEpisodeChecks) {
|
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`)
|
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
|
libraryItem.media.autoDownloadEpisodes = false
|
||||||
delete this.failedCheckMap[libraryItem.id]
|
delete this.failedCheckMap[libraryItem.id]
|
||||||
} else {
|
} else {
|
||||||
Logger.warn(`[PodcastManager] runEpisodeCheck ${this.failedCheckMap[libraryItem.id]} failed attempts at checking episodes for "${libraryItem.media.title}"`)
|
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) {
|
} else if (newEpisodes.length) {
|
||||||
delete this.failedCheckMap[libraryItem.id]
|
delete this.failedCheckMap[libraryItem.id]
|
||||||
|
@ -60,6 +60,38 @@ module.exports.notificationData = {
|
|||||||
errorMsg: 'Example error message'
|
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',
|
name: 'onTest',
|
||||||
requiresLibrary: false,
|
requiresLibrary: false,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user