aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/videos/live.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index c6f038079..e51658927 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -10,11 +10,11 @@ import { videoLiveAddValidator, videoLiveGetValidator, videoLiveUpdateValidator
10import { VideoLiveModel } from '@server/models/video/video-live' 10import { VideoLiveModel } from '@server/models/video/video-live'
11import { MVideoDetails, MVideoFullLight } from '@server/types/models' 11import { MVideoDetails, MVideoFullLight } from '@server/types/models'
12import { buildUUID, uuidToShort } from '@shared/extra-utils' 12import { buildUUID, uuidToShort } from '@shared/extra-utils'
13import { HttpStatusCode, LiveVideoCreate, LiveVideoLatencyMode, LiveVideoUpdate, VideoState } from '@shared/models' 13import { HttpStatusCode, LiveVideoCreate, LiveVideoLatencyMode, LiveVideoUpdate, UserRight, VideoState } from '@shared/models'
14import { logger } from '../../../helpers/logger' 14import { logger } from '../../../helpers/logger'
15import { sequelizeTypescript } from '../../../initializers/database' 15import { sequelizeTypescript } from '../../../initializers/database'
16import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail' 16import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail'
17import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' 17import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, optionalAuthenticate } from '../../../middlewares'
18import { VideoModel } from '../../../models/video/video' 18import { VideoModel } from '../../../models/video/video'
19 19
20const liveRouter = express.Router() 20const liveRouter = express.Router()
@@ -29,7 +29,7 @@ liveRouter.post('/live',
29) 29)
30 30
31liveRouter.get('/live/:videoId', 31liveRouter.get('/live/:videoId',
32 authenticate, 32 optionalAuthenticate,
33 asyncMiddleware(videoLiveGetValidator), 33 asyncMiddleware(videoLiveGetValidator),
34 getLiveVideo 34 getLiveVideo
35) 35)
@@ -52,7 +52,17 @@ export {
52function getLiveVideo (req: express.Request, res: express.Response) { 52function getLiveVideo (req: express.Request, res: express.Response) {
53 const videoLive = res.locals.videoLive 53 const videoLive = res.locals.videoLive
54 54
55 return res.json(videoLive.toFormattedJSON()) 55 return res.json(videoLive.toFormattedJSON(canSeePrivateLiveInformation(res)))
56}
57
58function canSeePrivateLiveInformation (res: express.Response) {
59 const user = res.locals.oauth?.token.User
60 if (!user) return false
61
62 if (user.hasRight(UserRight.GET_ANY_LIVE)) return true
63
64 const video = res.locals.videoAll
65 return video.VideoChannel.Account.userId === user.id
56} 66}
57 67
58async function updateLiveVideo (req: express.Request, res: express.Response) { 68async function updateLiveVideo (req: express.Request, res: express.Response) {