diff options
Diffstat (limited to 'server/controllers/api/config.ts')
-rw-r--r-- | server/controllers/api/config.ts | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index e0539c414..b25f739bb 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -3,13 +3,13 @@ import { omit } from 'lodash' | |||
3 | import { ServerConfig, UserRight } from '../../../shared' | 3 | import { ServerConfig, UserRight } from '../../../shared' |
4 | import { About } from '../../../shared/models/server/about.model' | 4 | import { About } from '../../../shared/models/server/about.model' |
5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' | 5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' |
6 | import { unlinkPromise, writeFilePromise } from '../../helpers/core-utils' | ||
7 | import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' | 6 | import { isSignupAllowed, isSignupAllowedForCurrentIP } from '../../helpers/signup' |
8 | import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' | 7 | import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' |
9 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' | 8 | import { asyncMiddleware, authenticate, ensureUserHasRight } from '../../middlewares' |
10 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' | 9 | import { customConfigUpdateValidator } from '../../middlewares/validators/config' |
11 | import { ClientHtml } from '../../lib/client-html' | 10 | import { ClientHtml } from '../../lib/client-html' |
12 | import { auditLoggerFactory, CustomConfigAuditView } from '../../helpers/audit-logger' | 11 | import { auditLoggerFactory, CustomConfigAuditView } from '../../helpers/audit-logger' |
12 | import { remove, writeJSON } from 'fs-extra' | ||
13 | 13 | ||
14 | const packageJSON = require('../../../../package.json') | 14 | const packageJSON = require('../../../../package.json') |
15 | const configRouter = express.Router() | 15 | const configRouter = express.Router() |
@@ -130,7 +130,7 @@ async function getCustomConfig (req: express.Request, res: express.Response, nex | |||
130 | } | 130 | } |
131 | 131 | ||
132 | async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { | 132 | async function deleteCustomConfig (req: express.Request, res: express.Response, next: express.NextFunction) { |
133 | await unlinkPromise(CONFIG.CUSTOM_FILE) | 133 | await remove(CONFIG.CUSTOM_FILE) |
134 | 134 | ||
135 | auditLogger.delete( | 135 | auditLogger.delete( |
136 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), | 136 | res.locals.oauth.token.User.Account.Actor.getIdentifier(), |
@@ -163,7 +163,7 @@ async function updateCustomConfig (req: express.Request, res: express.Response, | |||
163 | toUpdateJSON.instance['short_description'] = toUpdate.instance.shortDescription | 163 | toUpdateJSON.instance['short_description'] = toUpdate.instance.shortDescription |
164 | toUpdateJSON.instance['default_nsfw_policy'] = toUpdate.instance.defaultNSFWPolicy | 164 | toUpdateJSON.instance['default_nsfw_policy'] = toUpdate.instance.defaultNSFWPolicy |
165 | 165 | ||
166 | await writeFilePromise(CONFIG.CUSTOM_FILE, JSON.stringify(toUpdateJSON, undefined, 2)) | 166 | await writeJSON(CONFIG.CUSTOM_FILE, toUpdateJSON, { spaces: 2 }) |
167 | 167 | ||
168 | reloadConfig() | 168 | reloadConfig() |
169 | ClientHtml.invalidCache() | 169 | ClientHtml.invalidCache() |