aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-02-04 16:14:33 +0100
committerChocobozzz <me@florianbigard.com>2020-02-04 16:18:01 +0100
commit2c8776fc316da9719e5ebc55dfabdcac9e197ac4 (patch)
treeb8e8365092437ee69f2ef88d0e9d858fae15ec45 /server/controllers
parent943e5193905908dd1f2800d8810c635d86e3b28f (diff)
downloadPeerTube-2c8776fc316da9719e5ebc55dfabdcac9e197ac4.tar.gz
PeerTube-2c8776fc316da9719e5ebc55dfabdcac9e197ac4.tar.zst
PeerTube-2c8776fc316da9719e5ebc55dfabdcac9e197ac4.zip
Optimize view endpoint
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/activitypub/client.ts5
-rw-r--r--server/controllers/api/videos/index.ts4
2 files changed, 5 insertions, 4 deletions
diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts
index 9a5fd6084..395cfa0d5 100644
--- a/server/controllers/activitypub/client.ts
+++ b/server/controllers/activitypub/client.ts
@@ -1,4 +1,3 @@
1// Intercept ActivityPub client requests
2import * as express from 'express' 1import * as express from 'express'
3import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' 2import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
4import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' 3import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
@@ -37,10 +36,12 @@ import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike'
37import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' 36import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists'
38import { VideoPlaylistModel } from '../../models/video/video-playlist' 37import { VideoPlaylistModel } from '../../models/video/video-playlist'
39import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 38import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
40import { MAccountId, MActorId, MVideo, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models' 39import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models'
41 40
42const activityPubClientRouter = express.Router() 41const activityPubClientRouter = express.Router()
43 42
43// Intercept ActivityPub client requests
44
44activityPubClientRouter.get('/accounts?/:name', 45activityPubClientRouter.get('/accounts?/:name',
45 executeIfActivityPub, 46 executeIfActivityPub,
46 asyncMiddleware(localAccountValidator), 47 asyncMiddleware(localAccountValidator),
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 1d61f8427..eb46ea01f 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -135,7 +135,7 @@ videosRouter.get('/:id',
135 asyncMiddleware(getVideo) 135 asyncMiddleware(getVideo)
136) 136)
137videosRouter.post('/:id/views', 137videosRouter.post('/:id/views',
138 asyncMiddleware(videosGetValidator), 138 asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')),
139 asyncMiddleware(viewVideo) 139 asyncMiddleware(viewVideo)
140) 140)
141 141
@@ -458,7 +458,7 @@ async function getVideo (req: express.Request, res: express.Response) {
458} 458}
459 459
460async function viewVideo (req: express.Request, res: express.Response) { 460async function viewVideo (req: express.Request, res: express.Response) {
461 const videoInstance = res.locals.videoAll 461 const videoInstance = res.locals.onlyImmutableVideo
462 462
463 const ip = req.ip 463 const ip = req.ip
464 const exists = await Redis.Instance.doesVideoIPViewExist(ip, videoInstance.uuid) 464 const exists = await Redis.Instance.doesVideoIPViewExist(ip, videoInstance.uuid)