]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/video.ts
Fix pending subscription deletion
[github/Chocobozzz/PeerTube.git] / server / helpers / video.ts
index c2e15a705582001a076c5b10318dc3da478b7c44..c688ef1e3b108aa1d7f6b90f949b558870700f33 100644 (file)
@@ -2,9 +2,10 @@ import { Response } from 'express'
 import { CONFIG } from '@server/initializers/config'
 import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models'
 import { VideoPrivacy, VideoState } from '@shared/models'
+import { forceNumber } from '@shared/core-utils'
 
 function getVideoWithAttributes (res: Response) {
-  return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo || res.locals.onlyVideoWithRights
+  return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo
 }
 
 function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
@@ -14,14 +15,14 @@ function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
 }
 
 function isPrivacyForFederation (privacy: VideoPrivacy) {
-  const castedPrivacy = parseInt(privacy + '', 10)
+  const castedPrivacy = forceNumber(privacy)
 
   return castedPrivacy === VideoPrivacy.PUBLIC ||
     (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true && castedPrivacy === VideoPrivacy.UNLISTED)
 }
 
 function isStateForFederation (state: VideoState) {
-  const castedState = parseInt(state + '', 10)
+  const castedState = forceNumber(state)
 
   return castedState === VideoState.PUBLISHED || castedState === VideoState.WAITING_FOR_LIVE || castedState === VideoState.LIVE_ENDED
 }