Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add audit logs for video import

Chocobozzz7e5f9f001d5d
diff --git a/scripts/i18n/create-custom-files.ts b/scripts/i18n/create-custom-files.ts
index a297fa79cf..c4f8411e13 100755
--- a/scripts/i18n/create-custom-files.ts
+++ b/scripts/i18n/create-custom-files.ts
@@ -1,7 +1,14 @@
import * as jsToXliff12 from 'xliff/jsToXliff12'
import { writeFile } from 'fs'
import { join } from 'path'
-import { buildLanguages, VIDEO_CATEGORIES, VIDEO_LICENCES, VIDEO_PRIVACIES } from '../../server/initializers/constants'
+import {
+ buildLanguages,
+ VIDEO_CATEGORIES,
+ VIDEO_IMPORT_STATES,
+ VIDEO_LICENCES,
+ VIDEO_PRIVACIES,
+ VIDEO_STATES
+} from '../../server/initializers/constants'
import { values } from 'lodash'
type TranslationType = {
@@ -33,6 +40,8 @@ const serverKeys: any = {}
values(VIDEO_CATEGORIES)
.concat(values(VIDEO_LICENCES))
.concat(values(VIDEO_PRIVACIES))
+ .concat(values(VIDEO_STATES))
+ .concat(values(VIDEO_IMPORT_STATES))
.forEach(v => serverKeys[v] = v)
// More keys
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index ca7a5f9cac..33ac83cb93 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -1,11 +1,6 @@
import * as express from 'express'
-import { auditLoggerFactory } from '../../../helpers/audit-logger'
-import {
- asyncMiddleware,
- asyncRetryTransactionMiddleware,
- authenticate,
- videoImportAddValidator
-} from '../../../middlewares'
+import { auditLoggerFactory, VideoImportAuditView } from '../../../helpers/audit-logger'
+import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
import { CONFIG, IMAGE_MIMETYPE_EXT, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers'
import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl'
import { createReqFiles } from '../../../helpers/express-utils'
@@ -136,5 +131,7 @@ async function addVideoImport (req: express.Request, res: express.Response) {
}
await JobQueue.Instance.createJob({ type: 'video-import', payload })
+ auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoImportAuditView(videoImport.toFormattedJSON()))
+
return res.json(videoImport.toFormattedJSON())
}
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts
index f6eea7d904..031b1bfbd0 100644
--- a/server/helpers/audit-logger.ts
+++ b/server/helpers/audit-logger.ts
@@ -5,7 +5,7 @@ import * as flatten from 'flat'
import * as winston from 'winston'
import { CONFIG } from '../initializers'
import { jsonLoggerFormat, labelFormatter } from './logger'
-import { VideoDetails, User, VideoChannel, VideoAbuse } from '../../shared'
+import { VideoDetails, User, VideoChannel, VideoAbuse, VideoImport } from '../../shared'
import { VideoComment } from '../../shared/models/videos/video-comment.model'
import { CustomConfig } from '../../shared/models/server/custom-config.model'
@@ -119,6 +119,17 @@ class VideoAuditView extends EntityAuditView {
}
}
+const videoImportKeysToKeep = [
+ 'id',
+ 'targetUrl',
+ 'video-name'
+]
+class VideoImportAuditView extends EntityAuditView {
+ constructor (private videoImport: VideoImport) {
+ super(videoImportKeysToKeep, 'video-import', videoImport)
+ }
+}
+
const commentKeysToKeep = [
'id',
'text',
@@ -246,6 +257,7 @@ class CustomConfigAuditView extends EntityAuditView {
export {
auditLoggerFactory,
+ VideoImportAuditView,
VideoChannelAuditView,
CommentAuditView,
UserAuditView,