X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideo-blacklist.ts;h=3b90b1b9415982071d6deff43dacbeb18ec47b59;hb=bc90883f1a5e9c4ecb76ae358734b85be515af7f;hp=a0fc26e84a4ad2bca309db8f1c65d90ff8e390af;hpb=d5c8932a601c1854db0a2e399ccaf26e17385f1a;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index a0fc26e84..3b90b1b94 100644 --- a/server/lib/video-blacklist.ts +++ b/server/lib/video-blacklist.ts @@ -6,18 +6,18 @@ import { logger } from '../helpers/logger' import { UserAdminFlag } from '../../shared/models/users/user-flag.model' import { Hooks } from './plugins/hooks' import { Notifier } from './notifier' -import { MUser, MVideoBlacklist, MVideoWithBlacklistLight } from '@server/typings/models' +import { MUser, MVideoBlacklistVideo, MVideoWithBlacklistLight } from '@server/typings/models' async function autoBlacklistVideoIfNeeded (parameters: { - video: MVideoWithBlacklistLight, - user?: MUser, - isRemote: boolean, - isNew: boolean, - notify?: boolean, + video: MVideoWithBlacklistLight + user?: MUser + isRemote: boolean + isNew: boolean + notify?: boolean transaction?: Transaction }) { const { video, user, isRemote, isNew, notify = true, transaction } = parameters - const doAutoBlacklist = await Hooks.wrapPromiseFun( + const doAutoBlacklist = await Hooks.wrapFun( autoBlacklistNeeded, { video, user, isRemote, isNew }, 'filter:video.auto-blacklist.result' @@ -31,7 +31,7 @@ async function autoBlacklistVideoIfNeeded (parameters: { reason: 'Auto-blacklisted. Moderator review required.', type: VideoBlacklistType.AUTO_BEFORE_PUBLISHED } - const [ videoBlacklist ] = await VideoBlacklistModel.findOrCreate({ + const [ videoBlacklist ] = await VideoBlacklistModel.findOrCreate({ where: { videoId: video.id }, @@ -40,17 +40,19 @@ async function autoBlacklistVideoIfNeeded (parameters: { }) video.VideoBlacklist = videoBlacklist - if (notify) Notifier.Instance.notifyOnVideoAutoBlacklist(video) + videoBlacklist.Video = video + + if (notify) Notifier.Instance.notifyOnVideoAutoBlacklist(videoBlacklist) logger.info('Video %s auto-blacklisted.', video.uuid) return true } -async function autoBlacklistNeeded (parameters: { - video: MVideoWithBlacklistLight, - isRemote: boolean, - isNew: boolean, +function autoBlacklistNeeded (parameters: { + video: MVideoWithBlacklistLight + isRemote: boolean + isNew: boolean user?: MUser }) { const { user, video, isRemote, isNew } = parameters