]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/video-blacklist.ts
Fix live FPS limit
[github/Chocobozzz/PeerTube.git] / server / lib / video-blacklist.ts
index f1657e8f1dd509133ad1ea210e47824745b0b075..f6c66b6dd8a658d3391440927f0c3537c64aa6c6 100644 (file)
@@ -7,8 +7,8 @@ import {
   MVideoBlacklistVideo,
   MVideoFullLight,
   MVideoWithBlacklistLight
-} from '@server/typings/models'
-import { UserRight, VideoBlacklistCreate, VideoBlockType } from '../../shared/models'
+} from '@server/types/models'
+import { UserRight, VideoBlacklistCreate, VideoBlacklistType } from '../../shared/models'
 import { UserAdminFlag } from '../../shared/models/users/user-flag.model'
 import { logger } from '../helpers/logger'
 import { CONFIG } from '../initializers/config'
@@ -17,6 +17,7 @@ import { sendDeleteVideo } from './activitypub/send'
 import { federateVideoIfNeeded } from './activitypub/videos'
 import { Notifier } from './notifier'
 import { Hooks } from './plugins/hooks'
+import { LiveManager } from './live-manager'
 
 async function autoBlacklistVideoIfNeeded (parameters: {
   video: MVideoWithBlacklistLight
@@ -39,7 +40,7 @@ async function autoBlacklistVideoIfNeeded (parameters: {
     videoId: video.id,
     unfederated: true,
     reason: 'Auto-blacklisted. Moderator review required.',
-    type: VideoBlockType.AUTO_BEFORE_PUBLISHED
+    type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED
   }
   const [ videoBlacklist ] = await VideoBlacklistModel.findOrCreate<MVideoBlacklistVideo>({
     where: {
@@ -64,7 +65,7 @@ async function blacklistVideo (videoInstance: MVideoAccountLight, options: Video
     videoId: videoInstance.id,
     unfederated: options.unfederate === true,
     reason: options.reason,
-    type: VideoBlockType.MANUAL
+    type: VideoBlacklistType.MANUAL
   }
   )
   blacklist.Video = videoInstance
@@ -73,6 +74,10 @@ async function blacklistVideo (videoInstance: MVideoAccountLight, options: Video
     await sendDeleteVideo(videoInstance, undefined)
   }
 
+  if (videoInstance.isLive) {
+    LiveManager.Instance.stopSessionOf(videoInstance.id)
+  }
+
   Notifier.Instance.notifyOnVideoBlacklist(blacklist)
 }
 
@@ -94,7 +99,7 @@ async function unblacklistVideo (videoBlacklist: MVideoBlacklist, video: MVideoF
 
   Notifier.Instance.notifyOnVideoUnblacklist(video)
 
-  if (videoBlacklistType === VideoBlockType.AUTO_BEFORE_PUBLISHED) {
+  if (videoBlacklistType === VideoBlacklistType.AUTO_BEFORE_PUBLISHED) {
     Notifier.Instance.notifyOnVideoPublishedAfterRemovedFromAutoBlacklist(video)
 
     // Delete on object so new video notifications will send
@@ -126,7 +131,7 @@ function autoBlacklistNeeded (parameters: {
   if (!CONFIG.AUTO_BLACKLIST.VIDEOS.OF_USERS.ENABLED || !user) return false
   if (isRemote || isNew === false) return false
 
-  if (user.hasRight(UserRight.MANAGE_VIDEO_BLOCKS) || user.hasAdminFlag(UserAdminFlag.BYPASS_VIDEO_AUTO_BLOCK)) return false
+  if (user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) || user.hasAdminFlag(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST)) return false
 
   return true
 }