create stream info if not exists

This commit is contained in:
SrGooglo 2022-11-28 17:53:25 +00:00 committed by root
parent db50c6ec5a
commit 12ae6862bf

View File

@ -161,15 +161,26 @@ export default class StreamingController extends Controller {
user_id,
})
if (!info) {
info = new StreamingInfo({
user_id,
})
await info.save()
}
const category = await StreamingCategory.findOne({
key: info.category
})
}).catch((err) => {
console.error(err)
return {}
}) ?? {}
return res.json({
...info.toObject(),
["category"]: {
key: category.key,
label: category.label,
key: category?.key ?? "unknown",
label: category?.label ?? "Unknown",
}
})
}