From 6e46de095d7169355dd83030f6ce4a582304153a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 5 Oct 2018 11:15:06 +0200 Subject: Add user history and resume videos --- server/helpers/custom-validators/videos.ts | 4 +++- server/helpers/video.ts | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.ts index 9875c68bd..714f7ac95 100644 --- a/server/helpers/custom-validators/videos.ts +++ b/server/helpers/custom-validators/videos.ts @@ -154,7 +154,9 @@ function checkUserCanManageVideo (user: UserModel, video: VideoModel, right: Use } async function isVideoExist (id: string, res: Response, fetchType: VideoFetchType = 'all') { - const video = await fetchVideo(id, fetchType) + const userId = res.locals.oauth ? res.locals.oauth.token.User.id : undefined + + const video = await fetchVideo(id, fetchType, userId) if (video === null) { res.status(404) diff --git a/server/helpers/video.ts b/server/helpers/video.ts index b1577a6b0..1bd21467d 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts @@ -2,8 +2,8 @@ import { VideoModel } from '../models/video/video' type VideoFetchType = 'all' | 'only-video' | 'id' | 'none' -function fetchVideo (id: number | string, fetchType: VideoFetchType) { - if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id) +function fetchVideo (id: number | string, fetchType: VideoFetchType, userId?: number) { + if (fetchType === 'all') return VideoModel.loadAndPopulateAccountAndServerAndTags(id, undefined, userId) if (fetchType === 'only-video') return VideoModel.load(id) -- cgit v1.2.3