aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/videos/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/videos/index.ts')
-rw-r--r--server/controllers/api/videos/index.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 08bee97d3..393324819 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -6,6 +6,7 @@ import { processImage } from '../../../helpers/image-utils'
6import { logger } from '../../../helpers/logger' 6import { logger } from '../../../helpers/logger'
7import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger' 7import { auditLoggerFactory, getAuditIdFromRes, VideoAuditView } from '../../../helpers/audit-logger'
8import { getFormattedObjects, getServerActor } from '../../../helpers/utils' 8import { getFormattedObjects, getServerActor } from '../../../helpers/utils'
9import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
9import { 10import {
10 CONFIG, 11 CONFIG,
11 MIMETYPES, 12 MIMETYPES,
@@ -193,6 +194,7 @@ async function addVideo (req: express.Request, res: express.Response) {
193 channelId: res.locals.videoChannel.id, 194 channelId: res.locals.videoChannel.id,
194 originallyPublishedAt: videoInfo.originallyPublishedAt 195 originallyPublishedAt: videoInfo.originallyPublishedAt
195 } 196 }
197
196 const video = new VideoModel(videoData) 198 const video = new VideoModel(videoData)
197 video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object 199 video.url = getVideoActivityPubUrl(video) // We use the UUID, so set the URL after building the object
198 200
@@ -237,7 +239,7 @@ async function addVideo (req: express.Request, res: express.Response) {
237 // Create the torrent file 239 // Create the torrent file
238 await video.createTorrentAndSetInfoHash(videoFile) 240 await video.createTorrentAndSetInfoHash(videoFile)
239 241
240 const videoCreated = await sequelizeTypescript.transaction(async t => { 242 const { videoCreated, videoWasAutoBlacklisted } = await sequelizeTypescript.transaction(async t => {
241 const sequelizeOptions = { transaction: t } 243 const sequelizeOptions = { transaction: t }
242 244
243 const videoCreated = await video.save(sequelizeOptions) 245 const videoCreated = await video.save(sequelizeOptions)
@@ -266,15 +268,23 @@ async function addVideo (req: express.Request, res: express.Response) {
266 }, { transaction: t }) 268 }, { transaction: t })
267 } 269 }
268 270
269 await federateVideoIfNeeded(video, true, t) 271 const videoWasAutoBlacklisted = await autoBlacklistVideoIfNeeded(video, res.locals.oauth.token.User, t)
272
273 if (!videoWasAutoBlacklisted) {
274 await federateVideoIfNeeded(video, true, t)
275 }
270 276
271 auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON())) 277 auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
272 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) 278 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
273 279
274 return videoCreated 280 return { videoCreated, videoWasAutoBlacklisted }
275 }) 281 })
276 282
277 Notifier.Instance.notifyOnNewVideo(videoCreated) 283 if (videoWasAutoBlacklisted) {
284 Notifier.Instance.notifyOnVideoAutoBlacklist(videoCreated)
285 } else {
286 Notifier.Instance.notifyOnNewVideo(videoCreated)
287 }
278 288
279 if (video.state === VideoState.TO_TRANSCODE) { 289 if (video.state === VideoState.TO_TRANSCODE) {
280 // Put uuid because we don't have id auto incremented for now 290 // Put uuid because we don't have id auto incremented for now