From dc41ccc3770f08e0eb91245ca97720f2c51af188 Mon Sep 17 00:00:00 2001 From: Vito0912 <86927734+Vito0912@users.noreply.github.com> Date: Sat, 17 May 2025 18:08:05 +0200 Subject: [PATCH] prettier --- server/SocketAuthority.js | 4 +-- server/managers/NotificationManager.js | 7 ++-- server/utils/notifications.js | 45 ++++---------------------- 3 files changed, 11 insertions(+), 45 deletions(-) diff --git a/server/SocketAuthority.js b/server/SocketAuthority.js index 4df3fe61..fbc0f9a5 100644 --- a/server/SocketAuthority.js +++ b/server/SocketAuthority.js @@ -17,7 +17,7 @@ class SocketAuthority { constructor() { this.Server = null this.socketIoServers = [] - this.emittedNotifications = new Set(['item_added', 'item_updated', 'user_online', 'task_started', 'task_finished']); + this.emittedNotifications = new Set(['item_added', 'item_updated', 'user_online', 'task_started', 'task_finished']) /** @type {Object.} */ this.clients = {} @@ -95,7 +95,7 @@ class SocketAuthority { // Emits event to all admin user clients adminEmitter(evt, data) { - void this._fireNotification(evt, data); + void this._fireNotification(evt, data) for (const socketId in this.clients) { if (this.clients[socketId].user?.isAdminOrUp) { this.clients[socketId].socket.emit(evt, data) diff --git a/server/managers/NotificationManager.js b/server/managers/NotificationManager.js index 4ccdde19..deb80e71 100644 --- a/server/managers/NotificationManager.js +++ b/server/managers/NotificationManager.js @@ -189,11 +189,8 @@ class NotificationManager { 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)}`; - - console.log(eventData) - console.log(Object.keys(eventData)) + 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 diff --git a/server/utils/notifications.js b/server/utils/notifications.js index 82976711..fca52b71 100644 --- a/server/utils/notifications.js +++ b/server/utils/notifications.js @@ -72,9 +72,7 @@ const libraryItemTestData = { updatedAt: new Date('2024-05-15T18:30:36.940Z'), libraryId: 'fedcba98-7654-3210-fedc-ba9876543210', libraryFolderId: '11223344-5566-7788-99aa-bbccddeeff00' -}; - - +} module.exports.notificationData = { events: [ @@ -167,62 +165,33 @@ module.exports.notificationData = { requiresLibrary: false, description: 'Triggered when a user comes online', descriptionKey: 'NotificationOnUserOnlineDescription', - variables: [ 'id', 'username', 'type', 'session', 'lastSeen', 'createdAt'], + variables: ['id', 'username', 'type', 'session', 'lastSeen', 'createdAt'], defaults: { title: 'User Online: {{username}}', body: 'User {{username}} (ID: {{id}}) is now online.' - }, + } }, { name: 'onTaskStarted', requiresLibrary: false, description: 'Triggered when a task starts', descriptionKey: 'NotificationOnTaskStartedDescription', - variables: [ - 'id', 'action', - 'data.libraryId', 'data.libraryName', - 'title', 'titleKey', - 'titleSubs', 'description', - 'descriptionKey', 'descriptionSubs', - 'error', 'errorKey', - 'errorSubs', 'showSuccess', - 'isFailed', 'isFinished', - 'startedAt', 'finishedAt' - ], + variables: ['id', 'action', 'data.libraryId', 'data.libraryName', 'title', 'titleKey', 'titleSubs', 'description', 'descriptionKey', 'descriptionSubs', 'error', 'errorKey', 'errorSubs', 'showSuccess', 'isFailed', 'isFinished', 'startedAt', 'finishedAt'], defaults: { title: 'Task Started: {{title}}', body: 'Task {{title}} has started.\n\nAction: {{action}}\nLibrary ID: {{data.libraryId}}\nLibrary Name: {{data.libraryName}}' - }, + } }, { name: 'onTaskFinished', requiresLibrary: false, description: 'Triggered when a task finishes', descriptionKey: 'NotificationOnTaskFinishesDescription', - variables: [ - 'id', - 'action', - 'data.libraryId', - 'data.libraryName', - 'title', - 'titleKey', - 'titleSubs', - 'description', - 'descriptionKey', - 'descriptionSubs', - 'error', - 'errorKey', - 'errorSubs', - 'showSuccess', - 'isFailed', - 'isFinished', - 'startedAt', - 'finishedAt' - ], + variables: ['id', 'action', 'data.libraryId', 'data.libraryName', 'title', 'titleKey', 'titleSubs', 'description', 'descriptionKey', 'descriptionSubs', 'error', 'errorKey', 'errorSubs', 'showSuccess', 'isFailed', 'isFinished', 'startedAt', 'finishedAt'], defaults: { title: 'Task Started: {{title}}', body: 'Task {{title}} has started.\n\nAction: {{action}}\nLibrary ID: {{data.libraryId}}\nLibrary Name: {{data.libraryName}}' - }, + } }, // Test