diff options
Diffstat (limited to 'server/controllers/api/config.ts')
-rw-r--r-- | server/controllers/api/config.ts | 16 |
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' | |||
9 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' | 9 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' |
10 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' | 10 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' |
11 | import { ClientHtml } from '../../lib/client-html' | 11 | import { ClientHtml } from '../../lib/client-html' |
12 | import { CustomConfigAuditView, auditLoggerFactory } from '../../helpers/audit-logger' | ||
12 | 13 | ||
13 | const packageJSON = require('../../../../package.json') | 14 | const packageJSON = require('../../../../package.json') |
14 | const configRouter = express.Router() | 15 | const configRouter = express.Router() |
15 | 16 | ||
17 | const auditLogger = auditLoggerFactory('config') | ||
18 | |||
16 | configRouter.get('/about', getAbout) | 19 | configRouter.get('/about', getAbout) |
17 | configRouter.get('/', | 20 | configRouter.get('/', |
18 | asyncMiddleware(getConfig) | 21 | asyncMiddleware(getConfig) |
@@ -119,6 +122,11 @@ async function getCustomConfig (req: express.Request, res: express.Response, nex | |||
119 | async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 122 | async 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 | ||
130 | async function updateCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 138 | async 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 | ||