From 7eba5e1fa81c8e54cb8fe298a96e8070afa50921 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 4 Feb 2020 15:00:47 +0100 Subject: Add model cache for video When fetching only immutable attributes --- server/helpers/middlewares/videos.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'server/helpers/middlewares/videos.ts') diff --git a/server/helpers/middlewares/videos.ts b/server/helpers/middlewares/videos.ts index 74f529804..409f78650 100644 --- a/server/helpers/middlewares/videos.ts +++ b/server/helpers/middlewares/videos.ts @@ -2,7 +2,16 @@ import { Response } from 'express' import { fetchVideo, VideoFetchType } from '../video' import { UserRight } from '../../../shared/models/users' import { VideoChannelModel } from '../../models/video/video-channel' -import { MUser, MUserAccountId, MVideoAccountLight, MVideoFullLight, MVideoThumbnail, MVideoWithRights } from '@server/typings/models' +import { + MUser, + MUserAccountId, + MVideoAccountLight, + MVideoFullLight, + MVideoIdThumbnail, + MVideoImmutable, + MVideoThumbnail, + MVideoWithRights +} from '@server/typings/models' async function doesVideoExist (id: number | string, res: Response, fetchType: VideoFetchType = 'all') { const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined @@ -22,8 +31,12 @@ async function doesVideoExist (id: number | string, res: Response, fetchType: Vi res.locals.videoAll = video as MVideoFullLight break + case 'only-immutable-attributes': + res.locals.onlyImmutableVideo = video as MVideoImmutable + break + case 'id': - res.locals.videoId = video + res.locals.videoId = video as MVideoIdThumbnail break case 'only-video': -- cgit v1.2.3