X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideo-blacklist.ts;h=f6c66b6dd8a658d3391440927f0c3537c64aa6c6;hb=884d2c39ae23b44d0d037aaff0f66ad9ae0807ba;hp=f1657e8f1dd509133ad1ea210e47824745b0b075;hpb=5baee5fca418487e72ddcd6419d31bca8659b668;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index f1657e8f1..f6c66b6dd 100644 --- a/server/lib/video-blacklist.ts +++ b/server/lib/video-blacklist.ts @@ -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({ 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 }