X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Faudit-logger.ts;h=9b258dc3ae86bca21c848953e27566ceeb5452a9;hb=93905586ee198d4ac0a0fd5141a9fcbb10a94652;hp=031b1bfbd08650301eedfb7a6b6843944d455a9a;hpb=7e5f9f001d5de22c54748f935edc0c069028bb0e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts index 031b1bfbd..9b258dc3a 100644 --- a/server/helpers/audit-logger.ts +++ b/server/helpers/audit-logger.ts @@ -1,13 +1,19 @@ import * as path from 'path' +import * as express from 'express' import { diff } from 'deep-object-diff' import { chain } from 'lodash' import * as flatten from 'flat' import * as winston from 'winston' -import { CONFIG } from '../initializers' import { jsonLoggerFormat, labelFormatter } from './logger' -import { VideoDetails, User, VideoChannel, VideoAbuse, VideoImport } from '../../shared' +import { User, VideoAbuse, VideoChannel, VideoDetails, VideoImport } from '../../shared' import { VideoComment } from '../../shared/models/videos/video-comment.model' import { CustomConfig } from '../../shared/models/server/custom-config.model' +import { CONFIG } from '../initializers/config' +import { AUDIT_LOG_FILENAME } from '@server/initializers/constants' + +function getAuditIdFromRes (res: express.Response) { + return res.locals.oauth.token.User.username +} enum AUDIT_TYPE { CREATE = 'create', @@ -24,7 +30,7 @@ const auditLogger = winston.createLogger({ levels: { audit: 0 }, transports: [ new winston.transports.File({ - filename: path.join(CONFIG.STORAGE.LOG_DIR, 'peertube-audit.log'), + filename: path.join(CONFIG.STORAGE.LOG_DIR, AUDIT_LOG_FILENAME), level: 'audit', maxsize: 5242880, maxFiles: 5, @@ -111,7 +117,8 @@ const videoKeysToKeep = [ 'channel-uuid', 'channel-name', 'support', - 'commentsEnabled' + 'commentsEnabled', + 'downloadEnabled' ] class VideoAuditView extends EntityAuditView { constructor (private video: VideoDetails) { @@ -234,6 +241,7 @@ const customConfigKeysToKeep = [ 'cache-captions-size', 'signup-enabled', 'signup-limit', + 'signup-requiresEmailVerification', 'admin-email', 'user-videoQuota', 'transcoding-enabled', @@ -246,16 +254,16 @@ class CustomConfigAuditView extends EntityAuditView { const resolutionsDict = infos.transcoding.resolutions const resolutionsArray = [] Object.entries(resolutionsDict).forEach(([resolution, isEnabled]) => { - if (isEnabled) { - resolutionsArray.push(resolution) - } + if (isEnabled) resolutionsArray.push(resolution) }) - infos.transcoding.resolutions = resolutionsArray + Object.assign({}, infos, { transcoding: { resolutions: resolutionsArray } }) super(customConfigKeysToKeep, 'config', infos) } } export { + getAuditIdFromRes, + auditLoggerFactory, VideoImportAuditView, VideoChannelAuditView,