mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-31 13:51:30 +02:00
prettier
This commit is contained in:
parent
39f59e5189
commit
dc41ccc377
@ -17,7 +17,7 @@ class SocketAuthority {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.Server = null
|
this.Server = null
|
||||||
this.socketIoServers = []
|
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>} */
|
/** @type {Object.<string, SocketClient>} */
|
||||||
this.clients = {}
|
this.clients = {}
|
||||||
@ -95,7 +95,7 @@ class SocketAuthority {
|
|||||||
|
|
||||||
// Emits event to all admin user clients
|
// Emits event to all admin user clients
|
||||||
adminEmitter(evt, data) {
|
adminEmitter(evt, data) {
|
||||||
void this._fireNotification(evt, data);
|
void this._fireNotification(evt, data)
|
||||||
for (const socketId in this.clients) {
|
for (const socketId in this.clients) {
|
||||||
if (this.clients[socketId].user?.isAdminOrUp) {
|
if (this.clients[socketId].user?.isAdminOrUp) {
|
||||||
this.clients[socketId].socket.emit(evt, data)
|
this.clients[socketId].socket.emit(evt, data)
|
||||||
|
@ -189,11 +189,8 @@ class NotificationManager {
|
|||||||
fireNotificationFromSocket(eventName, eventData) {
|
fireNotificationFromSocket(eventName, eventData) {
|
||||||
if (!Database.notificationSettings.isUseable) return
|
if (!Database.notificationSettings.isUseable) return
|
||||||
|
|
||||||
const eventNameModified = eventName.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
|
const eventNameModified = eventName.replace(/_([a-z])/g, (_, c) => c.toUpperCase())
|
||||||
const eventKey = `on${eventNameModified.charAt(0).toUpperCase()}${eventNameModified.slice(1)}`;
|
const eventKey = `on${eventNameModified.charAt(0).toUpperCase()}${eventNameModified.slice(1)}`
|
||||||
|
|
||||||
console.log(eventData)
|
|
||||||
console.log(Object.keys(eventData))
|
|
||||||
|
|
||||||
if (!Database.notificationSettings.getHasActiveNotificationsForEvent(eventKey)) {
|
if (!Database.notificationSettings.getHasActiveNotificationsForEvent(eventKey)) {
|
||||||
// No logging to prevent console spam
|
// No logging to prevent console spam
|
||||||
|
@ -72,9 +72,7 @@ const libraryItemTestData = {
|
|||||||
updatedAt: new Date('2024-05-15T18:30:36.940Z'),
|
updatedAt: new Date('2024-05-15T18:30:36.940Z'),
|
||||||
libraryId: 'fedcba98-7654-3210-fedc-ba9876543210',
|
libraryId: 'fedcba98-7654-3210-fedc-ba9876543210',
|
||||||
libraryFolderId: '11223344-5566-7788-99aa-bbccddeeff00'
|
libraryFolderId: '11223344-5566-7788-99aa-bbccddeeff00'
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
module.exports.notificationData = {
|
module.exports.notificationData = {
|
||||||
events: [
|
events: [
|
||||||
@ -167,62 +165,33 @@ module.exports.notificationData = {
|
|||||||
requiresLibrary: false,
|
requiresLibrary: false,
|
||||||
description: 'Triggered when a user comes online',
|
description: 'Triggered when a user comes online',
|
||||||
descriptionKey: 'NotificationOnUserOnlineDescription',
|
descriptionKey: 'NotificationOnUserOnlineDescription',
|
||||||
variables: [ 'id', 'username', 'type', 'session', 'lastSeen', 'createdAt'],
|
variables: ['id', 'username', 'type', 'session', 'lastSeen', 'createdAt'],
|
||||||
defaults: {
|
defaults: {
|
||||||
title: 'User Online: {{username}}',
|
title: 'User Online: {{username}}',
|
||||||
body: 'User {{username}} (ID: {{id}}) is now online.'
|
body: 'User {{username}} (ID: {{id}}) is now online.'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'onTaskStarted',
|
name: 'onTaskStarted',
|
||||||
requiresLibrary: false,
|
requiresLibrary: false,
|
||||||
description: 'Triggered when a task starts',
|
description: 'Triggered when a task starts',
|
||||||
descriptionKey: 'NotificationOnTaskStartedDescription',
|
descriptionKey: 'NotificationOnTaskStartedDescription',
|
||||||
variables: [
|
variables: ['id', 'action', 'data.libraryId', 'data.libraryName', 'title', 'titleKey', 'titleSubs', 'description', 'descriptionKey', 'descriptionSubs', 'error', 'errorKey', 'errorSubs', 'showSuccess', 'isFailed', 'isFinished', 'startedAt', 'finishedAt'],
|
||||||
'id', 'action',
|
|
||||||
'data.libraryId', 'data.libraryName',
|
|
||||||
'title', 'titleKey',
|
|
||||||
'titleSubs', 'description',
|
|
||||||
'descriptionKey', 'descriptionSubs',
|
|
||||||
'error', 'errorKey',
|
|
||||||
'errorSubs', 'showSuccess',
|
|
||||||
'isFailed', 'isFinished',
|
|
||||||
'startedAt', 'finishedAt'
|
|
||||||
],
|
|
||||||
defaults: {
|
defaults: {
|
||||||
title: 'Task Started: {{title}}',
|
title: 'Task Started: {{title}}',
|
||||||
body: 'Task {{title}} has started.\n\nAction: {{action}}\nLibrary ID: {{data.libraryId}}\nLibrary Name: {{data.libraryName}}'
|
body: 'Task {{title}} has started.\n\nAction: {{action}}\nLibrary ID: {{data.libraryId}}\nLibrary Name: {{data.libraryName}}'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'onTaskFinished',
|
name: 'onTaskFinished',
|
||||||
requiresLibrary: false,
|
requiresLibrary: false,
|
||||||
description: 'Triggered when a task finishes',
|
description: 'Triggered when a task finishes',
|
||||||
descriptionKey: 'NotificationOnTaskFinishesDescription',
|
descriptionKey: 'NotificationOnTaskFinishesDescription',
|
||||||
variables: [
|
variables: ['id', 'action', 'data.libraryId', 'data.libraryName', 'title', 'titleKey', 'titleSubs', 'description', 'descriptionKey', 'descriptionSubs', 'error', 'errorKey', 'errorSubs', 'showSuccess', 'isFailed', 'isFinished', 'startedAt', 'finishedAt'],
|
||||||
'id',
|
|
||||||
'action',
|
|
||||||
'data.libraryId',
|
|
||||||
'data.libraryName',
|
|
||||||
'title',
|
|
||||||
'titleKey',
|
|
||||||
'titleSubs',
|
|
||||||
'description',
|
|
||||||
'descriptionKey',
|
|
||||||
'descriptionSubs',
|
|
||||||
'error',
|
|
||||||
'errorKey',
|
|
||||||
'errorSubs',
|
|
||||||
'showSuccess',
|
|
||||||
'isFailed',
|
|
||||||
'isFinished',
|
|
||||||
'startedAt',
|
|
||||||
'finishedAt'
|
|
||||||
],
|
|
||||||
defaults: {
|
defaults: {
|
||||||
title: 'Task Started: {{title}}',
|
title: 'Task Started: {{title}}',
|
||||||
body: 'Task {{title}} has started.\n\nAction: {{action}}\nLibrary ID: {{data.libraryId}}\nLibrary Name: {{data.libraryName}}'
|
body: 'Task {{title}} has started.\n\nAction: {{action}}\nLibrary ID: {{data.libraryId}}\nLibrary Name: {{data.libraryName}}'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Test
|
// Test
|
||||||
|
Loading…
Reference in New Issue
Block a user