fix /stream/info endpoint

This commit is contained in:
SrGooglo 2022-11-28 13:44:53 +00:00 committed by root
parent 81ea9d1b17
commit 8ed292a6f1
2 changed files with 12 additions and 7 deletions

View File

@ -25,7 +25,7 @@ export default class Livestream {
const { data } = await app.api.customRequest("main", { const { data } = await app.api.customRequest("main", {
method: "GET", method: "GET",
url: `/stream/info`, url: `/stream/info`,
data: { params: {
username, username,
} }
}) })

View File

@ -173,15 +173,20 @@ export default class StreamingController extends Controller {
"/stream/info": { "/stream/info": {
middleware: ["withAuthentication"], middleware: ["withAuthentication"],
fn: async (req, res) => { fn: async (req, res) => {
let user_id = req.user?._id let user_id = req.query.user_id
if (req.body.username || req.body.user_id) { if (!req.query.username && !req.query.user_id) {
return res.status(400).json({
error: "Invalid request, missing username"
})
}
if (!user_id) {
user_id = await User.findOne({ user_id = await User.findOne({
_id: req.body.user_id, username: req.query.username,
username: req.body.username, })
}).then((user) => user._id)
user_id = user_id.toString() user_id = user_id["_id"].toString()
} }
const info = await StreamingInfo.findOne({ const info = await StreamingInfo.findOne({