X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=server%2Fhelpers%2Faudit-logger.ts;h=af37bce16cd0da150f6d780df1e7b6346c42e404;hb=fd8710b897a67518d3a61c319e54b6a65ba443ef;hp=f6eea7d9046707b159e4b0396ac31bf46789a34d;hpb=80e36cd9facb56b330be3e4f1c5ba253cc78c308;p=oweals%2Fpeertube.git diff --git a/server/helpers/audit-logger.ts b/server/helpers/audit-logger.ts index f6eea7d90..af37bce16 100644 --- a/server/helpers/audit-logger.ts +++ b/server/helpers/audit-logger.ts @@ -1,14 +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 } 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' +function getAuditIdFromRes (res: express.Response) { + return res.locals.oauth.token.User.username +} + enum AUDIT_TYPE { CREATE = 'create', UPDATE = 'update', @@ -111,7 +116,8 @@ const videoKeysToKeep = [ 'channel-uuid', 'channel-name', 'support', - 'commentsEnabled' + 'commentsEnabled', + 'downloadEnabled' ] class VideoAuditView extends EntityAuditView { constructor (private video: VideoDetails) { @@ -119,6 +125,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', @@ -223,6 +240,7 @@ const customConfigKeysToKeep = [ 'cache-captions-size', 'signup-enabled', 'signup-limit', + 'signup-requiresEmailVerification', 'admin-email', 'user-videoQuota', 'transcoding-enabled', @@ -235,17 +253,18 @@ 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, CommentAuditView, UserAuditView,