X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideo-blacklist.ts;h=0984c0d7a7cef37434ca1bcc7b0f30faa987b8e8;hb=743dab5517d4501f6b35cfc795de6c8b6f41ebb3;hp=bd60c6201c93d1cde2ff762b717103f5ef2dc714;hpb=610d0be13b3d01f653ef269271dd667a57c85ef2;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index bd60c6201..0984c0d7a 100644 --- a/server/lib/video-blacklist.ts +++ b/server/lib/video-blacklist.ts @@ -1,4 +1,5 @@ import { Transaction } from 'sequelize' +import { afterCommitIfTransaction } from '@server/helpers/database-utils' import { sequelizeTypescript } from '@server/initializers/database' import { MUser, @@ -7,17 +8,20 @@ import { MVideoBlacklistVideo, MVideoFullLight, MVideoWithBlacklistLight -} from '@server/typings/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 { logger, loggerTagsFactory } from '../helpers/logger' import { CONFIG } from '../initializers/config' import { VideoBlacklistModel } from '../models/video/video-blacklist' import { sendDeleteVideo } from './activitypub/send' import { federateVideoIfNeeded } from './activitypub/videos' +import { LiveManager } from './live/live-manager' import { Notifier } from './notifier' import { Hooks } from './plugins/hooks' +const lTags = loggerTagsFactory('blacklist') + async function autoBlacklistVideoIfNeeded (parameters: { video: MVideoWithBlacklistLight user?: MUser @@ -52,9 +56,13 @@ async function autoBlacklistVideoIfNeeded (parameters: { videoBlacklist.Video = video - if (notify) Notifier.Instance.notifyOnVideoAutoBlacklist(videoBlacklist) + if (notify) { + afterCommitIfTransaction(transaction, () => { + Notifier.Instance.notifyOnVideoAutoBlacklist(videoBlacklist) + }) + } - logger.info('Video %s auto-blacklisted.', video.uuid) + logger.info('Video %s auto-blacklisted.', video.uuid, lTags(video.uuid)) return true } @@ -73,6 +81,10 @@ async function blacklistVideo (videoInstance: MVideoAccountLight, options: Video await sendDeleteVideo(videoInstance, undefined) } + if (videoInstance.isLive) { + LiveManager.Instance.stopSessionOf(videoInstance.id) + } + Notifier.Instance.notifyOnVideoBlacklist(blacklist) } @@ -126,7 +138,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_BLACKLIST) || user.hasAdminFlag(UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST)) return false + if (user.hasRight(UserRight.MANAGE_VIDEO_BLACKLIST) || user.hasAdminFlag(UserAdminFlag.BYPASS_VIDEO_AUTO_BLACKLIST)) return false return true }