X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fvideo-blacklist.ts;h=cb1ea834c46dc32a0b5f52a875999db98fe961f3;hb=6cc8a0dfad49addf620a42e78d6f38003a67b310;hp=f6c66b6dd8a658d3391440927f0c3537c64aa6c6;hpb=a5cf76afa378aae81af2a9b0ce548e5d2582f832;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/video-blacklist.ts b/server/lib/video-blacklist.ts index f6c66b6dd..cb1ea834c 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, @@ -8,16 +9,18 @@ import { MVideoFullLight, MVideoWithBlacklistLight } from '@server/types/models' -import { UserRight, VideoBlacklistCreate, VideoBlacklistType } from '../../shared/models' +import { LiveVideoError, 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' -import { LiveManager } from './live-manager' + +const lTags = loggerTagsFactory('blacklist') async function autoBlacklistVideoIfNeeded (parameters: { video: MVideoWithBlacklistLight @@ -53,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 } @@ -66,8 +73,7 @@ async function blacklistVideo (videoInstance: MVideoAccountLight, options: Video unfederated: options.unfederate === true, reason: options.reason, type: VideoBlacklistType.MANUAL - } - ) + }) blacklist.Video = videoInstance if (options.unfederate === true) { @@ -75,7 +81,7 @@ async function blacklistVideo (videoInstance: MVideoAccountLight, options: Video } if (videoInstance.isLive) { - LiveManager.Instance.stopSessionOf(videoInstance.id) + LiveManager.Instance.stopSessionOf(videoInstance.uuid, LiveVideoError.BLACKLISTED) } Notifier.Instance.notifyOnVideoBlacklist(blacklist)