first draft

This commit is contained in:
Vito0912 2025-05-15 20:51:57 +02:00
parent 25c7e95a64
commit 04ba949182
No known key found for this signature in database
GPG key ID: 29A3D509FE70B237
3 changed files with 123 additions and 1 deletions

View file

@ -90,6 +90,14 @@ class NotificationManager {
this.triggerNotification('onBackupFailed', eventData)
}
/**
* @param
*/
async onItemUpdated(libraryItem) {
console.log('onItemUpdated', libraryItem)
this.triggerNotification('onItemUpdated', libraryItem)
}
onTest() {
this.triggerNotification('onTest')
}
@ -124,7 +132,7 @@ class NotificationManager {
}
await Database.updateSetting(Database.notificationSettings)
SocketAuthority.emitter('notifications_updated', Database.notificationSettings.toJSON())
//SocketAuthority.emitter('notifications_updated', Database.notificationSettings.toJSON())
this.notificationFinished()
}
@ -184,5 +192,26 @@ class NotificationManager {
return false
})
}
fireNotificationFromSocket(eventName, eventData) {
if (!Database.notificationSettings.isUseable) return
const eventNameModified = eventName.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
const eventKey = `on${eventNameModified.charAt(0).toUpperCase()}${eventNameModified.slice(1)}`;
if (!Database.notificationSettings.getHasActiveNotificationsForEvent(eventKey)) {
// No logging to prevent console spam
Logger.debug(`[NotificationManager] fireSocketNotification: No active notifications`)
return
}
Logger.debug(`[NotificationManager] fireNotificationFromSocket: ${eventKey} event fired`)
switch (eventKey) {
case 'onItemUpdated':
void this.onItemUpdated(eventData)
break
}
}
}
module.exports = new NotificationManager()