diff options
Diffstat (limited to 'server/controllers/api/videos')
-rw-r--r-- | server/controllers/api/videos/blacklist.ts | 3 | ||||
-rw-r--r-- | server/controllers/api/videos/import.ts | 9 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 19 |
3 files changed, 17 insertions, 14 deletions
diff --git a/server/controllers/api/videos/blacklist.ts b/server/controllers/api/videos/blacklist.ts index 0ec518e0d..9ff494def 100644 --- a/server/controllers/api/videos/blacklist.ts +++ b/server/controllers/api/videos/blacklist.ts | |||
@@ -115,6 +115,7 @@ async function removeVideoFromBlacklistController (req: express.Request, res: ex | |||
115 | const videoBlacklistType = videoBlacklist.type | 115 | const videoBlacklistType = videoBlacklist.type |
116 | 116 | ||
117 | await videoBlacklist.destroy({ transaction: t }) | 117 | await videoBlacklist.destroy({ transaction: t }) |
118 | video.VideoBlacklist = undefined | ||
118 | 119 | ||
119 | // Re federate the video | 120 | // Re federate the video |
120 | if (unfederated === true) { | 121 | if (unfederated === true) { |
@@ -131,7 +132,7 @@ async function removeVideoFromBlacklistController (req: express.Request, res: ex | |||
131 | 132 | ||
132 | // Delete on object so new video notifications will send | 133 | // Delete on object so new video notifications will send |
133 | delete video.VideoBlacklist | 134 | delete video.VideoBlacklist |
134 | Notifier.Instance.notifyOnNewVideo(video) | 135 | Notifier.Instance.notifyOnNewVideoIfNeeded(video) |
135 | } | 136 | } |
136 | 137 | ||
137 | logger.info('Video %s removed from blacklist.', res.locals.video.uuid) | 138 | logger.info('Video %s removed from blacklist.', res.locals.video.uuid) |
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts index 47c6f122c..1f08fe20a 100644 --- a/server/controllers/api/videos/import.ts +++ b/server/controllers/api/videos/import.ts | |||
@@ -245,7 +245,14 @@ function insertIntoDB (parameters: { | |||
245 | if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) | 245 | if (thumbnailModel) await videoCreated.addAndSaveThumbnail(thumbnailModel, t) |
246 | if (previewModel) await videoCreated.addAndSaveThumbnail(previewModel, t) | 246 | if (previewModel) await videoCreated.addAndSaveThumbnail(previewModel, t) |
247 | 247 | ||
248 | await autoBlacklistVideoIfNeeded({ video, user, isRemote: false, isNew: true, transaction: t }) | 248 | await autoBlacklistVideoIfNeeded({ |
249 | video, | ||
250 | user, | ||
251 | notify: false, | ||
252 | isRemote: false, | ||
253 | isNew: true, | ||
254 | transaction: t | ||
255 | }) | ||
249 | 256 | ||
250 | // Set tags to the video | 257 | // Set tags to the video |
251 | if (tags) { | 258 | if (tags) { |
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 6a79a16c7..973bf1123 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -235,7 +235,7 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
235 | // Create the torrent file | 235 | // Create the torrent file |
236 | await video.createTorrentAndSetInfoHash(videoFile) | 236 | await video.createTorrentAndSetInfoHash(videoFile) |
237 | 237 | ||
238 | const { videoCreated, videoWasAutoBlacklisted } = await sequelizeTypescript.transaction(async t => { | 238 | const { videoCreated } = await sequelizeTypescript.transaction(async t => { |
239 | const sequelizeOptions = { transaction: t } | 239 | const sequelizeOptions = { transaction: t } |
240 | 240 | ||
241 | const videoCreated = await video.save(sequelizeOptions) | 241 | const videoCreated = await video.save(sequelizeOptions) |
@@ -268,23 +268,22 @@ async function addVideo (req: express.Request, res: express.Response) { | |||
268 | }, { transaction: t }) | 268 | }, { transaction: t }) |
269 | } | 269 | } |
270 | 270 | ||
271 | const videoWasAutoBlacklisted = await autoBlacklistVideoIfNeeded({ | 271 | await autoBlacklistVideoIfNeeded({ |
272 | video, | 272 | video, |
273 | user: res.locals.oauth.token.User, | 273 | user: res.locals.oauth.token.User, |
274 | isRemote: false, | 274 | isRemote: false, |
275 | isNew: true, | 275 | isNew: true, |
276 | transaction: t | 276 | transaction: t |
277 | }) | 277 | }) |
278 | if (!videoWasAutoBlacklisted) await federateVideoIfNeeded(video, true, t) | 278 | await federateVideoIfNeeded(video, true, t) |
279 | 279 | ||
280 | auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON())) | 280 | auditLogger.create(getAuditIdFromRes(res), new VideoAuditView(videoCreated.toFormattedDetailsJSON())) |
281 | logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) | 281 | logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) |
282 | 282 | ||
283 | return { videoCreated, videoWasAutoBlacklisted } | 283 | return { videoCreated } |
284 | }) | 284 | }) |
285 | 285 | ||
286 | if (videoWasAutoBlacklisted) Notifier.Instance.notifyOnVideoAutoBlacklist(videoCreated) | 286 | Notifier.Instance.notifyOnNewVideoIfNeeded(videoCreated) |
287 | else Notifier.Instance.notifyOnNewVideo(videoCreated) | ||
288 | 287 | ||
289 | if (video.state === VideoState.TO_TRANSCODE) { | 288 | if (video.state === VideoState.TO_TRANSCODE) { |
290 | // Put uuid because we don't have id auto incremented for now | 289 | // Put uuid because we don't have id auto incremented for now |
@@ -413,11 +412,7 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
413 | }) | 412 | }) |
414 | 413 | ||
415 | const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE | 414 | const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE |
416 | 415 | await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t) | |
417 | // Don't send update if the video was unfederated | ||
418 | if (!videoInstanceUpdated.VideoBlacklist || videoInstanceUpdated.VideoBlacklist.unfederated === false) { | ||
419 | await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t) | ||
420 | } | ||
421 | 416 | ||
422 | auditLogger.update( | 417 | auditLogger.update( |
423 | getAuditIdFromRes(res), | 418 | getAuditIdFromRes(res), |
@@ -430,7 +425,7 @@ async function updateVideo (req: express.Request, res: express.Response) { | |||
430 | }) | 425 | }) |
431 | 426 | ||
432 | if (wasUnlistedVideo || wasPrivateVideo) { | 427 | if (wasUnlistedVideo || wasPrivateVideo) { |
433 | Notifier.Instance.notifyOnNewVideo(videoInstanceUpdated) | 428 | Notifier.Instance.notifyOnNewVideoIfNeeded(videoInstanceUpdated) |
434 | } | 429 | } |
435 | 430 | ||
436 | Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated }) | 431 | Hooks.runAction('action:api.video.updated', { video: videoInstanceUpdated }) |