mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-28 01:16:10 +02:00
moved flatten after O(1)
This commit is contained in:
parent
7b62b6be86
commit
39f59e5189
@ -33,7 +33,7 @@ class SocketAuthority {
|
|||||||
if (!this.emittedNotifications.has(event)) return
|
if (!this.emittedNotifications.has(event)) return
|
||||||
Logger.debug(`[SocketAuthority] fireNotification - ${event}`)
|
Logger.debug(`[SocketAuthority] fireNotification - ${event}`)
|
||||||
|
|
||||||
NotificationManager.fireNotificationFromSocket(event, payload)
|
NotificationManager.fireNotificationFromSocket(event, flattenAny(payload))
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -69,7 +69,7 @@ class SocketAuthority {
|
|||||||
* @param {Function} [filter] optional filter function to only send event to specific users
|
* @param {Function} [filter] optional filter function to only send event to specific users
|
||||||
*/
|
*/
|
||||||
emitter(evt, data, filter = null) {
|
emitter(evt, data, filter = null) {
|
||||||
void this._fireNotification(evt, flattenAny(data))
|
void this._fireNotification(evt, data)
|
||||||
for (const socketId in this.clients) {
|
for (const socketId in this.clients) {
|
||||||
if (this.clients[socketId].user) {
|
if (this.clients[socketId].user) {
|
||||||
if (filter && !filter(this.clients[socketId].user)) continue
|
if (filter && !filter(this.clients[socketId].user)) continue
|
||||||
@ -81,7 +81,7 @@ class SocketAuthority {
|
|||||||
|
|
||||||
// Emits event to all clients for a specific user
|
// Emits event to all clients for a specific user
|
||||||
clientEmitter(userId, evt, data) {
|
clientEmitter(userId, evt, data) {
|
||||||
void this._fireNotification(evt, flattenAny(data))
|
void this._fireNotification(evt, data)
|
||||||
const clients = this.getClientsForUser(userId)
|
const clients = this.getClientsForUser(userId)
|
||||||
if (!clients.length) {
|
if (!clients.length) {
|
||||||
return Logger.debug(`[SocketAuthority] clientEmitter - no clients found for user ${userId}`)
|
return Logger.debug(`[SocketAuthority] clientEmitter - no clients found for user ${userId}`)
|
||||||
@ -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, flattenAny(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)
|
||||||
@ -111,7 +111,7 @@ class SocketAuthority {
|
|||||||
* @param {import('./models/LibraryItem')} libraryItem
|
* @param {import('./models/LibraryItem')} libraryItem
|
||||||
*/
|
*/
|
||||||
libraryItemEmitter(evt, libraryItem) {
|
libraryItemEmitter(evt, libraryItem) {
|
||||||
void this._fireNotification(evt, flattenAny(libraryItem.toOldJSONMinified()))
|
void this._fireNotification(evt, libraryItem.toOldJSONMinified())
|
||||||
for (const socketId in this.clients) {
|
for (const socketId in this.clients) {
|
||||||
if (this.clients[socketId].user?.checkCanAccessLibraryItem(libraryItem)) {
|
if (this.clients[socketId].user?.checkCanAccessLibraryItem(libraryItem)) {
|
||||||
this.clients[socketId].socket.emit(evt, libraryItem.toOldJSONExpanded())
|
this.clients[socketId].socket.emit(evt, libraryItem.toOldJSONExpanded())
|
||||||
|
Loading…
Reference in New Issue
Block a user