From ec249b70dbd14326757903c770e98c9ae2fa43ae Mon Sep 17 00:00:00 2001 From: srgooglo Date: Thu, 12 May 2022 19:27:26 +0200 Subject: [PATCH] added `get/stream_config_from_username` endpoint --- .../controllers/StreamingController/index.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/packages/server/src/controllers/StreamingController/index.js b/packages/server/src/controllers/StreamingController/index.js index 7612a402..9d94b51f 100644 --- a/packages/server/src/controllers/StreamingController/index.js +++ b/packages/server/src/controllers/StreamingController/index.js @@ -34,6 +34,31 @@ export default class StreamingController extends Controller { } get = { + "/stream_info_from_username": async (req, res) => { + const { username } = req.query + + const userspace = await StreamingKey.findOne({ username }) + + if (!userspace) { + return res.status(403).json({ + error: "This username has not a streaming key" + }) + } + + // TODO: meanwhile linebridge remote linkers are in development we gonna use this methods to fetch + const { data } = await axios.get(`${streamingServerAPIUri}/streams`, { + params: { + username: userspace.username + } + }).catch((error) => { + res.status(500).json({ + error: `Failed to fetch streams from [${streamingServerAPIAddress}]: ${error.message}` + }) + return false + }) + + return res.json(data) + }, "/streams": async (req, res) => { // TODO: meanwhile linebridge remote linkers are in development we gonna use this methods to fetch const { data } = await axios.get(`${streamingServerAPIUri}/streams`).catch((error) => {