Added broadcast for alreadyInQueue and loginNeededToDownload errors
This commit is contained in:
parent
a82c4c303e
commit
cc82ee6376
@ -17,7 +17,7 @@ export const sessionDZ: any = {}
|
||||
const deemixPlugins = {}
|
||||
|
||||
export const listener = {
|
||||
send(key: string, data: any) {
|
||||
send(key: string, data?: any) {
|
||||
console.log(key, data)
|
||||
wss.clients.forEach(client => {
|
||||
if (client.readyState === WebSocket.OPEN) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
// @ts-expect-error
|
||||
import { Deezer } from 'deezer-js'
|
||||
import { ApiHandler } from '../../../types'
|
||||
import { sessionDZ, addToQueue, settings } from '../../../main'
|
||||
import { sessionDZ, addToQueue, settings, listener } from '../../../main'
|
||||
|
||||
const path: ApiHandler['path'] = '/addToQueue'
|
||||
|
||||
@ -19,13 +19,16 @@ const handler: ApiHandler['handler'] = async (req, res) => {
|
||||
} catch (e) {
|
||||
switch (e.name) {
|
||||
case 'AlreadyInQueue':
|
||||
res.send({ result: false, errid: e.name, data: { url, bitrate, obj: e.data } })
|
||||
res.send({ result: false, errid: e.name, data: { url, bitrate, obj: e.item } })
|
||||
listener.send('alreadyInQueue', e.item)
|
||||
break
|
||||
case 'NotLoggedIn':
|
||||
res.send({ result: false, errid: e.name, data: { url, bitrate } })
|
||||
listener.send('loginNeededToDownload')
|
||||
break
|
||||
default:
|
||||
console.error(e)
|
||||
res.send({ result: false, errid: e.name, data: { url, bitrate } })
|
||||
break
|
||||
}
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user