X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideo-blacklist.ts;h=0984c0d7a7cef37434ca1bcc7b0f30faa987b8e8;hb=5037e0e474044d7fc04092158784395a001e5c25;hp=1ee92d22c61ea6faa39f3c7598f861f513feb234;hpb=3487330d308166afb542cbacae0475693c0b059e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index 1ee92d22c..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) }