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.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index 101183eab..c9365da08 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -5,6 +5,7 @@ import { renamePromise } from '../../../helpers/core-utils'
5import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils' 5import { getVideoFileFPS, getVideoFileResolution } from '../../../helpers/ffmpeg-utils'
6import { processImage } from '../../../helpers/image-utils' 6import { processImage } from '../../../helpers/image-utils'
7import { logger } from '../../../helpers/logger' 7import { logger } from '../../../helpers/logger'
8import { auditLoggerFactory, VideoAuditView } from '../../../helpers/audit-logger'
8import { getFormattedObjects, getServerActor, resetSequelizeInstance } from '../../../helpers/utils' 9import { getFormattedObjects, getServerActor, resetSequelizeInstance } from '../../../helpers/utils'
9import { 10import {
10 CONFIG, 11 CONFIG,
@@ -53,7 +54,9 @@ import { VideoFilter } from '../../../../shared/models/videos/video-query.type'
53import { createReqFiles, buildNSFWFilter } from '../../../helpers/express-utils' 54import { createReqFiles, buildNSFWFilter } from '../../../helpers/express-utils'
54import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' 55import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
55import { videoCaptionsRouter } from './captions' 56import { videoCaptionsRouter } from './captions'
57import { videoImportsRouter } from './import'
56 58
59const auditLogger = auditLoggerFactory('videos')
57const videosRouter = express.Router() 60const videosRouter = express.Router()
58 61
59const reqVideoFileAdd = createReqFiles( 62const reqVideoFileAdd = createReqFiles(
@@ -79,6 +82,7 @@ videosRouter.use('/', blacklistRouter)
79videosRouter.use('/', rateVideoRouter) 82videosRouter.use('/', rateVideoRouter)
80videosRouter.use('/', videoCommentRouter) 83videosRouter.use('/', videoCommentRouter)
81videosRouter.use('/', videoCaptionsRouter) 84videosRouter.use('/', videoCaptionsRouter)
85videosRouter.use('/', videoImportsRouter)
82 86
83videosRouter.get('/categories', listVideoCategories) 87videosRouter.get('/categories', listVideoCategories)
84videosRouter.get('/licences', listVideoLicences) 88videosRouter.get('/licences', listVideoLicences)
@@ -158,7 +162,6 @@ async function addVideo (req: express.Request, res: express.Response) {
158 const videoData = { 162 const videoData = {
159 name: videoInfo.name, 163 name: videoInfo.name,
160 remote: false, 164 remote: false,
161 extname: extname(videoPhysicalFile.filename),
162 category: videoInfo.category, 165 category: videoInfo.category,
163 licence: videoInfo.licence, 166 licence: videoInfo.licence,
164 language: videoInfo.language, 167 language: videoInfo.language,
@@ -247,6 +250,7 @@ async function addVideo (req: express.Request, res: express.Response) {
247 250
248 await federateVideoIfNeeded(video, true, t) 251 await federateVideoIfNeeded(video, true, t)
249 252
253 auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoAuditView(videoCreated.toFormattedDetailsJSON()))
250 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid) 254 logger.info('Video with name %s and uuid %s created.', videoInfo.name, videoCreated.uuid)
251 255
252 return videoCreated 256 return videoCreated
@@ -273,6 +277,7 @@ async function addVideo (req: express.Request, res: express.Response) {
273async function updateVideo (req: express.Request, res: express.Response) { 277async function updateVideo (req: express.Request, res: express.Response) {
274 const videoInstance: VideoModel = res.locals.video 278 const videoInstance: VideoModel = res.locals.video
275 const videoFieldsSave = videoInstance.toJSON() 279 const videoFieldsSave = videoInstance.toJSON()
280 const oldVideoAuditView = new VideoAuditView(videoInstance.toFormattedDetailsJSON())
276 const videoInfoToUpdate: VideoUpdate = req.body 281 const videoInfoToUpdate: VideoUpdate = req.body
277 const wasPrivateVideo = videoInstance.privacy === VideoPrivacy.PRIVATE 282 const wasPrivateVideo = videoInstance.privacy === VideoPrivacy.PRIVATE
278 283
@@ -344,9 +349,14 @@ async function updateVideo (req: express.Request, res: express.Response) {
344 349
345 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE 350 const isNewVideo = wasPrivateVideo && videoInstanceUpdated.privacy !== VideoPrivacy.PRIVATE
346 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t) 351 await federateVideoIfNeeded(videoInstanceUpdated, isNewVideo, t)
347 })
348 352
349 logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid) 353 auditLogger.update(
354 res.locals.oauth.token.User.Account.Actor.getIdentifier(),
355 new VideoAuditView(videoInstanceUpdated.toFormattedDetailsJSON()),
356 oldVideoAuditView
357 )
358 logger.info('Video with name %s and uuid %s updated.', videoInstance.name, videoInstance.uuid)
359 })
350 } catch (err) { 360 } catch (err) {
351 // Force fields we want to update 361 // Force fields we want to update
352 // If the transaction is retried, sequelize will think the object has not changed 362 // If the transaction is retried, sequelize will think the object has not changed
@@ -423,6 +433,7 @@ async function removeVideo (req: express.Request, res: express.Response) {
423 await videoInstance.destroy({ transaction: t }) 433 await videoInstance.destroy({ transaction: t })
424 }) 434 })
425 435
436 auditLogger.delete(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoAuditView(videoInstance.toFormattedDetailsJSON()))
426 logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid) 437 logger.info('Video with name %s and uuid %s deleted.', videoInstance.name, videoInstance.uuid)
427 438
428 return res.type('json').status(204).end() 439 return res.type('json').status(204).end()