mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-14 19:34:57 +02:00
Update:Only emit library socket events to users with access to lib
This commit is contained in:
parent
725f8eecdb
commit
0e292c64c4
3 changed files with 42 additions and 29 deletions
|
@ -31,9 +31,13 @@ class SocketAuthority {
|
|||
}
|
||||
|
||||
// Emits event to all authorized clients
|
||||
emitter(evt, data) {
|
||||
// optional filter function to only send event to specific users
|
||||
// TODO: validate that filter is actually a function
|
||||
emitter(evt, data, filter = null) {
|
||||
for (const socketId in this.clients) {
|
||||
if (this.clients[socketId].user) {
|
||||
if (filter && !filter(this.clients[socketId].user)) continue
|
||||
|
||||
this.clients[socketId].socket.emit(evt, data)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue