]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/live.ts
Add ability to redirect users on external auth
[github/Chocobozzz/PeerTube.git] / server / controllers / live.ts
index fa4c2cc1a300c5e9b3045a145b8863fac071d972..81008f120d213cdb5b9975b9c3958d0e4e2a2ea4 100644 (file)
@@ -1,10 +1,13 @@
-import * as express from 'express'
+import cors from 'cors'
+import express from 'express'
 import { mapToJSON } from '@server/helpers/core-utils'
-import { LiveManager } from '@server/lib/live-manager'
+import { LiveSegmentShaStore } from '@server/lib/live'
+import { HttpStatusCode } from '@shared/models'
 
 const liveRouter = express.Router()
 
 liveRouter.use('/segments-sha256/:videoUUID',
+  cors(),
   getSegmentsSha256
 )
 
@@ -19,10 +22,10 @@ export {
 function getSegmentsSha256 (req: express.Request, res: express.Response) {
   const videoUUID = req.params.videoUUID
 
-  const result = LiveManager.Instance.getSegmentsSha256(videoUUID)
+  const result = LiveSegmentShaStore.Instance.getSegmentsSha256(videoUUID)
 
   if (!result) {
-    return res.sendStatus(404)
+    return res.status(HttpStatusCode.NOT_FOUND_404).end()
   }
 
   return res.json(mapToJSON(result))