mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-26 13:51:16 +02:00
prettier
This commit is contained in:
parent
39f59e5189
commit
dc41ccc377
@ -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.<string, SocketClient>} */
|
||||
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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user