mirror of https://github.com/Chocobozzz/PeerTube
Add audit logs for video import
parent
2b86fe7274
commit
7e5f9f001d
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue