From 2c8776fc316da9719e5ebc55dfabdcac9e197ac4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Feb 2020 16:14:33 +0100 Subject: Optimize view endpoint --- server/controllers/activitypub/client.ts | 5 +++-- server/controllers/api/videos/index.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'server/controllers') 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 @@ -// Intercept ActivityPub client requests import * as express from 'express' import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos' import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' @@ -37,10 +36,12 @@ import { buildDislikeActivity } from '../../lib/activitypub/send/send-dislike' import { videoPlaylistElementAPGetValidator, videoPlaylistsGetValidator } from '../../middlewares/validators/videos/video-playlists' import { VideoPlaylistModel } from '../../models/video/video-playlist' import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' -import { MAccountId, MActorId, MVideo, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models' +import { MAccountId, MActorId, MVideoAPWithoutCaption, MVideoId } from '@server/typings/models' const activityPubClientRouter = express.Router() +// Intercept ActivityPub client requests + activityPubClientRouter.get('/accounts?/:name', executeIfActivityPub, 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', asyncMiddleware(getVideo) ) videosRouter.post('/:id/views', - asyncMiddleware(videosGetValidator), + asyncMiddleware(videosCustomGetValidator('only-immutable-attributes')), asyncMiddleware(viewVideo) ) @@ -458,7 +458,7 @@ async function getVideo (req: express.Request, res: express.Response) { } async function viewVideo (req: express.Request, res: express.Response) { - const videoInstance = res.locals.videoAll + const videoInstance = res.locals.onlyImmutableVideo const ip = req.ip const exists = await Redis.Instance.doesVideoIPViewExist(ip, videoInstance.uuid) -- cgit v1.2.3