aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/config.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/config.ts')
-rw-r--r--server/controllers/api/config.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts
index 9c1b2818c..411b13539 100644
--- a/server/controllers/api/config.ts
+++ b/server/controllers/api/config.ts
@@ -9,10 +9,13 @@ import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers'
9import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' 9import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares'
10import { customConfigUpdateValidator } from '../../middlewares/validators/config' 10import { customConfigUpdateValidator } from '../../middlewares/validators/config'
11import { ClientHtml } from '../../lib/client-html' 11import { ClientHtml } from '../../lib/client-html'
12import { CustomConfigAuditView, auditLoggerFactory } from '../../helpers/audit-logger'
12 13
13const packageJSON = require('../../../../package.json') 14const packageJSON = require('../../../../package.json')
14const configRouter = express.Router() 15const configRouter = express.Router()
15 16
17const auditLogger = auditLoggerFactory('config')
18
16configRouter.get('/about', getAbout) 19configRouter.get('/about', getAbout)
17configRouter.get('/', 20configRouter.get('/',
18 asyncMiddleware(getConfig) 21 asyncMiddleware(getConfig)
@@ -119,6 +122,11 @@ async function getCustomConfig (req: express.Request, res: express.Response, nex
119async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { 122async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
120 await unlinkPromise(CONFIG.CUSTOM_FILE) 123 await unlinkPromise(CONFIG.CUSTOM_FILE)
121 124
125 auditLogger.delete(
126 res.locals.oauth.token.User.Account.Actor.getIdentifier(),
127 new CustomConfigAuditView(customConfig())
128 )
129
122 reloadConfig() 130 reloadConfig()
123 ClientHtml.invalidCache() 131 ClientHtml.invalidCache()
124 132
@@ -129,6 +137,7 @@ async function deleteCustomConfig (req: express.Request, res: express.Response,
129 137
130async function updateCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { 138async function updateCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) {
131 const toUpdate: CustomConfig = req.body 139 const toUpdate: CustomConfig = req.body
140 const oldCustomConfigAuditKeys = new CustomConfigAuditView(customConfig())
132 141
133 // Force number conversion 142 // Force number conversion
134 toUpdate.cache.previews.size = parseInt('' + toUpdate.cache.previews.size, 10) 143 toUpdate.cache.previews.size = parseInt('' + toUpdate.cache.previews.size, 10)
@@ -150,6 +159,13 @@ async function updateCustomConfig (req: express.Request, res: express.Response,
150 ClientHtml.invalidCache() 159 ClientHtml.invalidCache()
151 160
152 const data = customConfig() 161 const data = customConfig()
162
163 auditLogger.update(
164 res.locals.oauth.token.User.Account.Actor.getIdentifier(),
165 new CustomConfigAuditView(data),
166 oldCustomConfigAuditKeys
167 )
168
153 return res.json(data).end() 169 return res.json(data).end()
154} 170}
155 171