]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/video-playlists.ts
Add user adminFlags
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / video-playlists.ts
index c217a39bf9ed76d16ea52227784202e54f27213a..2fe426560350683eb17a76f874a81cd084955aa9 100644 (file)
@@ -1,6 +1,6 @@
 import { exists } from './misc'
 import * as validator from 'validator'
-import { CONSTRAINTS_FIELDS, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES } from '../../initializers'
+import { CONSTRAINTS_FIELDS, VIDEO_PLAYLIST_PRIVACIES, VIDEO_PLAYLIST_TYPES } from '../../initializers/constants'
 import * as express from 'express'
 import { VideoPlaylistModel } from '../../models/video/video-playlist'
 
@@ -26,8 +26,10 @@ function isVideoPlaylistTypeValid (value: any) {
   return exists(value) && VIDEO_PLAYLIST_TYPES[ value ] !== undefined
 }
 
-async function isVideoPlaylistExist (id: number | string, res: express.Response) {
-  const videoPlaylist = await VideoPlaylistModel.loadWithAccountAndChannel(id, undefined)
+async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: 'summary' | 'all' = 'summary') {
+  const videoPlaylist = fetchType === 'summary'
+    ? await VideoPlaylistModel.loadWithAccountAndChannelSummary(id, undefined)
+    : await VideoPlaylistModel.loadWithAccountAndChannel(id, undefined)
 
   if (!videoPlaylist) {
     res.status(404)
@@ -44,7 +46,7 @@ async function isVideoPlaylistExist (id: number | string, res: express.Response)
 // ---------------------------------------------------------------------------
 
 export {
-  isVideoPlaylistExist,
+  doesVideoPlaylistExist,
   isVideoPlaylistNameValid,
   isVideoPlaylistDescriptionValid,
   isVideoPlaylistPrivacyValid,