fixes??
This commit is contained in:
1 parent
8bb81b394a
commit
8a444b5f4c
2 files changed
+23
-20
No files matched your search
+1
-1
@@ -195,7 +195,7 @@ class Music {
|
||||
const allowed = ['Play', 'Pause', 'Stop', 'Next', 'Previous', 'PlayPause']
|
||||
|
||||
if (!allowed.includes(action)) return
|
||||
// if (this.status == newStateLookup[action]) return
|
||||
if (this.status == newStateLookup[action]) return
|
||||
|
||||
let controller = {
|
||||
linux: controlLinux,
|
||||
|
||||
+22
-19
@@ -16,24 +16,23 @@ export default class Qr {
|
||||
return async (req, res, next) => {
|
||||
if (req.path !== '/qr') return next()
|
||||
|
||||
try {
|
||||
if (this.host === null) {
|
||||
res.status(500).send('QR code generation is not configured')
|
||||
throw new Error('SERVER_HOST is not defined')
|
||||
}
|
||||
|
||||
if (!this.#cache) {
|
||||
const payload = this.#payload()
|
||||
this.#cache = await this.#generate(payload)
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'image/png')
|
||||
res.setHeader('Cache-Control', 'public, max-age=3600')
|
||||
res.send(this.#cache)
|
||||
} catch (error) {
|
||||
logger.error('http', 'QR code generation error:', error)
|
||||
res.status(500).send('Failed to generate QR code')
|
||||
try {
|
||||
if (this.#host === null) {
|
||||
res.status(500).send('QR code generation is not configured')
|
||||
throw new Error('SERVER_HOST is not defined')
|
||||
}
|
||||
if (!this.#cache) {
|
||||
const payload = this.#payload()
|
||||
this.#cache = await this.#generate(payload)
|
||||
}
|
||||
|
||||
res.setHeader('Content-Type', 'image/png')
|
||||
res.setHeader('Cache-Control', 'public, max-age=3600')
|
||||
res.send(this.#cache)
|
||||
} catch (error) {
|
||||
logger.error('http', 'QR code generation error:', error)
|
||||
res.status(500).send('Failed to generate QR code')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +46,11 @@ export default class Qr {
|
||||
}
|
||||
|
||||
static #payload() {
|
||||
const port = env.HTTP_PORT
|
||||
return `http://${this.#host}:${port}/player`
|
||||
const port = env.HTTP_PORT,
|
||||
portSuffix = port == 80 || port === 443 ? '' : `:${port}`,
|
||||
url = `http://${this.#host}${portSuffix}/player`
|
||||
|
||||
logger.debug('Qr', 'Link:', url)
|
||||
return url
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user