aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-03 10:26:47 +0200
committerChocobozzz <me@florianbigard.com>2018-08-06 11:19:16 +0200
commit7e5f9f001d5de22c54748f935edc0c069028bb0e (patch)
treed07ac657b1bc49a61b6f57f2d2ba8af66dd105bd /server
parent2b86fe727490fc0e42c0d147d98c0df612d5507c (diff)
downloadPeerTube-7e5f9f001d5de22c54748f935edc0c069028bb0e.tar.gz
PeerTube-7e5f9f001d5de22c54748f935edc0c069028bb0e.tar.zst
PeerTube-7e5f9f001d5de22c54748f935edc0c069028bb0e.zip
Add audit logs for video import
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/videos/import.ts11
-rw-r--r--server/helpers/audit-logger.ts14
2 files changed, 17 insertions, 8 deletions
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index ca7a5f9ca..33ac83cb9 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -1,11 +1,6 @@
1import * as express from 'express' 1import * as express from 'express'
2import { auditLoggerFactory } from '../../../helpers/audit-logger' 2import { auditLoggerFactory, VideoImportAuditView } from '../../../helpers/audit-logger'
3import { 3import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
4 asyncMiddleware,
5 asyncRetryTransactionMiddleware,
6 authenticate,
7 videoImportAddValidator
8} from '../../../middlewares'
9import { CONFIG, IMAGE_MIMETYPE_EXT, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers' 4import { CONFIG, IMAGE_MIMETYPE_EXT, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers'
10import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl' 5import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl'
11import { createReqFiles } from '../../../helpers/express-utils' 6import { createReqFiles } from '../../../helpers/express-utils'
@@ -136,5 +131,7 @@ async function addVideoImport (req: express.Request, res: express.Response) {
136 } 131 }
137 await JobQueue.Instance.createJob({ type: 'video-import', payload }) 132 await JobQueue.Instance.createJob({ type: 'video-import', payload })
138 133
134 auditLogger.create(res.locals.oauth.token.User.Account.Actor.getIdentifier(), new VideoImportAuditView(videoImport.toFormattedJSON()))
135
139 return res.json(videoImport.toFormattedJSON()) 136 return res.json(videoImport.toFormattedJSON())
140} 137}
diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts
index f6eea7d90..031b1bfbd 100644
--- a/server/helpers/audit-logger.ts
+++ b/server/helpers/audit-logger.ts
@@ -5,7 +5,7 @@ import * as flatten from 'flat'
5import * as winston from 'winston' 5import * as winston from 'winston'
6import { CONFIG } from '../initializers' 6import { CONFIG } from '../initializers'
7import { jsonLoggerFormat, labelFormatter } from './logger' 7import { jsonLoggerFormat, labelFormatter } from './logger'
8import { VideoDetails, User, VideoChannel, VideoAbuse } from '../../shared' 8import { VideoDetails, User, VideoChannel, VideoAbuse, VideoImport } from '../../shared'
9import { VideoComment } from '../../shared/models/videos/video-comment.model' 9import { VideoComment } from '../../shared/models/videos/video-comment.model'
10import { CustomConfig } from '../../shared/models/server/custom-config.model' 10import { CustomConfig } from '../../shared/models/server/custom-config.model'
11 11
@@ -119,6 +119,17 @@ class VideoAuditView extends EntityAuditView {
119 } 119 }
120} 120}
121 121
122const videoImportKeysToKeep = [
123 'id',
124 'targetUrl',
125 'video-name'
126]
127class VideoImportAuditView extends EntityAuditView {
128 constructor (private videoImport: VideoImport) {
129 super(videoImportKeysToKeep, 'video-import', videoImport)
130 }
131}
132
122const commentKeysToKeep = [ 133const commentKeysToKeep = [
123 'id', 134 'id',
124 'text', 135 'text',
@@ -246,6 +257,7 @@ class CustomConfigAuditView extends EntityAuditView {
246 257
247export { 258export {
248 auditLoggerFactory, 259 auditLoggerFactory,
260 VideoImportAuditView,
249 VideoChannelAuditView, 261 VideoChannelAuditView,
250 CommentAuditView, 262 CommentAuditView,
251 UserAuditView, 263 UserAuditView,