mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 02:54:15 +00:00
fix bad syntax
This commit is contained in:
parent
5bdb882d6f
commit
a3aae340d8
@ -277,89 +277,89 @@ export default class StreamingController extends Controller {
|
|||||||
if (info) {
|
if (info) {
|
||||||
return res.json(info)
|
return res.json(info)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
"/streaming/publish": async (req, res) => {
|
},
|
||||||
const { app, stream, tcUrl } = req.body
|
"/streaming/publish": async (req, res) => {
|
||||||
|
const { app, stream, tcUrl } = req.body
|
||||||
|
|
||||||
const streaming = await this.methods.pushToLocalList({
|
const streaming = await this.methods.pushToLocalList({
|
||||||
app,
|
app,
|
||||||
stream,
|
stream,
|
||||||
tcUrl
|
tcUrl
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
res.status(500).json({
|
||||||
|
code: 1,
|
||||||
|
error: err.message
|
||||||
|
})
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
if (streaming) {
|
||||||
|
global.wsInterface.io.emit(`streaming.new`, {
|
||||||
|
username: streaming.username,
|
||||||
|
})
|
||||||
|
|
||||||
|
return res.json({
|
||||||
|
code: 0,
|
||||||
|
status: "ok"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/streaming/unpublish": async (req, res) => {
|
||||||
|
const { stream } = req.body
|
||||||
|
|
||||||
|
const streaming = await this.methods.removeFromLocalList({
|
||||||
|
stream
|
||||||
|
}).catch((err) => {
|
||||||
|
res.status(500).json({
|
||||||
|
code: 2,
|
||||||
|
status: err.message
|
||||||
|
})
|
||||||
|
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
|
||||||
|
if (streaming) {
|
||||||
|
global.wsInterface.io.emit(`streaming.end`, {
|
||||||
|
username: streaming.username,
|
||||||
|
})
|
||||||
|
|
||||||
|
return res.json({
|
||||||
|
code: 0,
|
||||||
|
status: "ok"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"/regenerate_streaming_key": {
|
||||||
|
middlewares: ["withAuthentication"],
|
||||||
|
fn: async (req, res) => {
|
||||||
|
// check if the user already has a key
|
||||||
|
let streamingKey = await StreamingKey.findOne({
|
||||||
|
user_id: req.user._id.toString()
|
||||||
|
})
|
||||||
|
|
||||||
|
// if exists, delete it
|
||||||
|
|
||||||
|
if (streamingKey) {
|
||||||
|
await streamingKey.remove()
|
||||||
|
}
|
||||||
|
|
||||||
|
// generate a new key
|
||||||
|
const newKey = await this.methods.genereteKey(req.user._id.toString()).catch(err => {
|
||||||
res.status(500).json({
|
res.status(500).json({
|
||||||
code: 1,
|
error: `Cannot generate a new key: ${err.message}`,
|
||||||
error: err.message
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
if (streaming) {
|
if (!newKey) {
|
||||||
global.wsInterface.io.emit(`streaming.new`, {
|
|
||||||
username: streaming.username,
|
|
||||||
})
|
|
||||||
|
|
||||||
return res.json({
|
|
||||||
code: 0,
|
|
||||||
status: "ok"
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/streaming/unpublish": async (req, res) => {
|
|
||||||
const { stream } = req.body
|
|
||||||
|
|
||||||
const streaming = await this.methods.removeFromLocalList({
|
|
||||||
stream
|
|
||||||
}).catch((err) => {
|
|
||||||
res.status(500).json({
|
|
||||||
code: 2,
|
|
||||||
status: err.message
|
|
||||||
})
|
|
||||||
|
|
||||||
return false
|
return false
|
||||||
})
|
|
||||||
|
|
||||||
if (streaming) {
|
|
||||||
global.wsInterface.io.emit(`streaming.end`, {
|
|
||||||
username: streaming.username,
|
|
||||||
})
|
|
||||||
|
|
||||||
return res.json({
|
|
||||||
code: 0,
|
|
||||||
status: "ok"
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"/regenerate_streaming_key": {
|
|
||||||
middlewares: ["withAuthentication"],
|
|
||||||
fn: async (req, res) => {
|
|
||||||
// check if the user already has a key
|
|
||||||
let streamingKey = await StreamingKey.findOne({
|
|
||||||
user_id: req.user._id.toString()
|
|
||||||
})
|
|
||||||
|
|
||||||
// if exists, delete it
|
return res.json(newKey)
|
||||||
|
|
||||||
if (streamingKey) {
|
|
||||||
await streamingKey.remove()
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate a new key
|
|
||||||
const newKey = await this.methods.genereteKey(req.user._id.toString()).catch(err => {
|
|
||||||
res.status(500).json({
|
|
||||||
error: `Cannot generate a new key: ${err.message}`,
|
|
||||||
})
|
|
||||||
|
|
||||||
return false
|
|
||||||
})
|
|
||||||
|
|
||||||
if (!newKey) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return res.json(newKey)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user