From 0283eaac2a8e73006c66df3cf5bb9012e37450e5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Aug 2019 13:52:49 +0200 Subject: Cleanup model types --- server/helpers/middlewares/video-channels.ts | 4 ++-- server/helpers/middlewares/videos.ts | 4 ++-- server/helpers/video.ts | 19 +++++++++++++++---- 3 files changed, 19 insertions(+), 8 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/middlewares/video-channels.ts b/server/helpers/middlewares/video-channels.ts index 17b7692c5..1595ecd94 100644 --- a/server/helpers/middlewares/video-channels.ts +++ b/server/helpers/middlewares/video-channels.ts @@ -1,6 +1,6 @@ import * as express from 'express' import { VideoChannelModel } from '../../models/video/video-channel' -import { MChannelActorAccountDefault } from '../../typings/models' +import { MChannelAccountDefault } from '@server/typings/models' async function doesLocalVideoChannelNameExist (name: string, res: express.Response) { const videoChannel = await VideoChannelModel.loadLocalByNameAndPopulateAccount(name) @@ -28,7 +28,7 @@ export { doesVideoChannelNameWithHostExist } -function processVideoChannelExist (videoChannel: MChannelActorAccountDefault, res: express.Response) { +function processVideoChannelExist (videoChannel: MChannelAccountDefault, res: express.Response) { if (!videoChannel) { res.status(404) .json({ error: 'Video channel not found' }) diff --git a/server/helpers/middlewares/videos.ts b/server/helpers/middlewares/videos.ts index 964f0c91a..74f529804 100644 --- a/server/helpers/middlewares/videos.ts +++ b/server/helpers/middlewares/videos.ts @@ -2,7 +2,7 @@ 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, MVideoWithRights } from '@server/typings/models' +import { MUser, MUserAccountId, MVideoAccountLight, MVideoFullLight, 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 @@ -27,7 +27,7 @@ async function doesVideoExist (id: number | string, res: Response, fetchType: Vi break case 'only-video': - res.locals.onlyVideo = video + res.locals.onlyVideo = video as MVideoThumbnail break case 'only-video-with-rights': diff --git a/server/helpers/video.ts b/server/helpers/video.ts index 26a72ac5c..d066e2b1f 100644 --- a/server/helpers/video.ts +++ b/server/helpers/video.ts @@ -1,6 +1,12 @@ import { VideoModel } from '../models/video/video' import * as Bluebird from 'bluebird' -import { MVideoAccountAllFiles, MVideoFullLight, MVideoThumbnail, MVideoWithRights, MVideoIdThumbnail } from '@server/typings/models' +import { + MVideoAccountLightBlacklistAllFiles, + MVideoFullLight, + MVideoIdThumbnail, + MVideoThumbnail, + MVideoWithRights +} from '@server/typings/models' import { Response } from 'express' type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' @@ -30,10 +36,10 @@ function fetchVideo ( type VideoFetchByUrlType = 'all' | 'only-video' -function fetchVideoByUrl (url: string, fetchType: 'all'): Bluebird +function fetchVideoByUrl (url: string, fetchType: 'all'): Bluebird function fetchVideoByUrl (url: string, fetchType: 'only-video'): Bluebird -function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird | Bluebird -function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird | Bluebird { +function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird +function fetchVideoByUrl (url: string, fetchType: VideoFetchByUrlType): Bluebird { if (fetchType === 'all') return VideoModel.loadByUrlAndPopulateAccount(url) if (fetchType === 'only-video') return VideoModel.loadByUrl(url) @@ -43,10 +49,15 @@ function getVideo (res: Response) { return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights || res.locals.videoId } +function getVideoWithAttributes (res: Response) { + return res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights +} + export { VideoFetchType, VideoFetchByUrlType, fetchVideo, getVideo, + getVideoWithAttributes, fetchVideoByUrl } -- cgit v1.2.3