mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-09 19:01:41 +00:00
Added an On Library Item notifcation event
This commit is contained in:
parent
c377b57601
commit
bfbe5aa91e
10 changed files with 3530 additions and 3804 deletions
|
|
@ -3,6 +3,7 @@ const Logger = require('../Logger')
|
|||
const SocketAuthority = require('../SocketAuthority')
|
||||
const Database = require('../Database')
|
||||
const { notificationData } = require('../utils/notifications')
|
||||
const Json = require('../libs/archiver/lib/plugins/json')
|
||||
|
||||
class NotificationManager {
|
||||
constructor() {
|
||||
|
|
@ -90,6 +91,30 @@ class NotificationManager {
|
|||
this.triggerNotification('onBackupFailed', eventData)
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import('../models/LibraryItem')} libraryItem
|
||||
*/
|
||||
async onLibraryItemAdded(libraryItem) {
|
||||
|
||||
try {
|
||||
if (!Database.notificationSettings.isUseable) return
|
||||
|
||||
if (!Database.notificationSettings.getHasActiveNotificationsForEvent('onLibraryItemAdded')) {
|
||||
Logger.debug(`[NotificationManager] onLibraryItemAdded: No active notifications`)
|
||||
return
|
||||
}
|
||||
|
||||
const eventData = {
|
||||
itemTitle: libraryItem.title,
|
||||
itemAuthor: libraryItem.authorNamesFirstLast,
|
||||
mediaType: libraryItem.mediaType
|
||||
}
|
||||
this.triggerNotification('onLibraryItemAdded', eventData)
|
||||
} catch (error) {
|
||||
Logger.error('[NotificationManager] Error in onLibraryItemAdded:', error)
|
||||
}
|
||||
}
|
||||
|
||||
onTest() {
|
||||
this.triggerNotification('onTest')
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue