Add audit logs for video import
This commit is contained in:
parent
2b86fe7274
commit
7e5f9f001d
3 changed files with 27 additions and 9 deletions
|
@ -1,7 +1,14 @@
|
||||||
import * as jsToXliff12 from 'xliff/jsToXliff12'
|
import * as jsToXliff12 from 'xliff/jsToXliff12'
|
||||||
import { writeFile } from 'fs'
|
import { writeFile } from 'fs'
|
||||||
import { join } from 'path'
|
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'
|
import { values } from 'lodash'
|
||||||
|
|
||||||
type TranslationType = {
|
type TranslationType = {
|
||||||
|
@ -33,6 +40,8 @@ const serverKeys: any = {}
|
||||||
values(VIDEO_CATEGORIES)
|
values(VIDEO_CATEGORIES)
|
||||||
.concat(values(VIDEO_LICENCES))
|
.concat(values(VIDEO_LICENCES))
|
||||||
.concat(values(VIDEO_PRIVACIES))
|
.concat(values(VIDEO_PRIVACIES))
|
||||||
|
.concat(values(VIDEO_STATES))
|
||||||
|
.concat(values(VIDEO_IMPORT_STATES))
|
||||||
.forEach(v => serverKeys[v] = v)
|
.forEach(v => serverKeys[v] = v)
|
||||||
|
|
||||||
// More keys
|
// More keys
|
||||||
|
|
|
@ -1,11 +1,6 @@
|
||||||
import * as express from 'express'
|
import * as express from 'express'
|
||||||
import { auditLoggerFactory } from '../../../helpers/audit-logger'
|
import { auditLoggerFactory, VideoImportAuditView } from '../../../helpers/audit-logger'
|
||||||
import {
|
import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
|
||||||
asyncMiddleware,
|
|
||||||
asyncRetryTransactionMiddleware,
|
|
||||||
authenticate,
|
|
||||||
videoImportAddValidator
|
|
||||||
} from '../../../middlewares'
|
|
||||||
import { CONFIG, IMAGE_MIMETYPE_EXT, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers'
|
import { CONFIG, IMAGE_MIMETYPE_EXT, PREVIEWS_SIZE, sequelizeTypescript, THUMBNAILS_SIZE } from '../../../initializers'
|
||||||
import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl'
|
import { getYoutubeDLInfo, YoutubeDLInfo } from '../../../helpers/youtube-dl'
|
||||||
import { createReqFiles } from '../../../helpers/express-utils'
|
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 })
|
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())
|
return res.json(videoImport.toFormattedJSON())
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import * as flatten from 'flat'
|
||||||
import * as winston from 'winston'
|
import * as winston from 'winston'
|
||||||
import { CONFIG } from '../initializers'
|
import { CONFIG } from '../initializers'
|
||||||
import { jsonLoggerFormat, labelFormatter } from './logger'
|
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 { VideoComment } from '../../shared/models/videos/video-comment.model'
|
||||||
import { CustomConfig } from '../../shared/models/server/custom-config.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 = [
|
const commentKeysToKeep = [
|
||||||
'id',
|
'id',
|
||||||
'text',
|
'text',
|
||||||
|
@ -246,6 +257,7 @@ class CustomConfigAuditView extends EntityAuditView {
|
||||||
|
|
||||||
export {
|
export {
|
||||||
auditLoggerFactory,
|
auditLoggerFactory,
|
||||||
|
VideoImportAuditView,
|
||||||
VideoChannelAuditView,
|
VideoChannelAuditView,
|
||||||
CommentAuditView,
|
CommentAuditView,
|
||||||
UserAuditView,
|
UserAuditView,
|
||||||
|
|
Loading…
Reference in a new issue