mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
create stream info if not exists
This commit is contained in:
parent
db50c6ec5a
commit
12ae6862bf
@ -161,15 +161,26 @@ export default class StreamingController extends Controller {
|
|||||||
user_id,
|
user_id,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!info) {
|
||||||
|
info = new StreamingInfo({
|
||||||
|
user_id,
|
||||||
|
})
|
||||||
|
|
||||||
|
await info.save()
|
||||||
|
}
|
||||||
|
|
||||||
const category = await StreamingCategory.findOne({
|
const category = await StreamingCategory.findOne({
|
||||||
key: info.category
|
key: info.category
|
||||||
})
|
}).catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
return {}
|
||||||
|
}) ?? {}
|
||||||
|
|
||||||
return res.json({
|
return res.json({
|
||||||
...info.toObject(),
|
...info.toObject(),
|
||||||
["category"]: {
|
["category"]: {
|
||||||
key: category.key,
|
key: category?.key ?? "unknown",
|
||||||
label: category.label,
|
label: category?.label ?? "Unknown",
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user