aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-04-22 09:50:20 +0200
committerChocobozzz <me@florianbigard.com>2022-04-22 09:50:20 +0200
commit961cbe4269e5f34639e29310fb3d90a6cb1bd6bc (patch)
tree06404c72c25a95238e7ef8a6bdfcb90d40c8649c /server/controllers/api/videos
parent4ec52d04dcc5d664612331f8e08d7d90da990415 (diff)
downloadPeerTube-961cbe4269e5f34639e29310fb3d90a6cb1bd6bc.tar.gz
PeerTube-961cbe4269e5f34639e29310fb3d90a6cb1bd6bc.tar.zst
PeerTube-961cbe4269e5f34639e29310fb3d90a6cb1bd6bc.zip
Fix getting live by anonymous user
Diffstat (limited to 'server/controllers/api/videos')
-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) {