mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
refactor: #12623, add filter:config.get.admin
to add admin only config values add /api/admin/config to retrieve config object with admin values included
This commit is contained in:
@@ -168,6 +168,8 @@ paths:
|
||||
$ref: 'read/admin/upload/file.yaml'
|
||||
/api/admin/uploadDefaultAvatar:
|
||||
$ref: 'read/admin/uploadDefaultAvatar.yaml'
|
||||
/api/admin/config:
|
||||
$ref: 'read/admin/config.yaml'
|
||||
/api/config:
|
||||
$ref: 'read/config.yaml'
|
||||
/api/users:
|
||||
|
||||
290
public/openapi/read/admin/config.yaml
Normal file
290
public/openapi/read/admin/config.yaml
Normal file
@@ -0,0 +1,290 @@
|
||||
get:
|
||||
tags:
|
||||
- admin
|
||||
summary: Get forum settings and admin only settings
|
||||
description: This route retrieves forum settings and user-specific settings for client-side and admin-side options on the forum.
|
||||
responses:
|
||||
"200":
|
||||
description: ""
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
relative_path:
|
||||
type: string
|
||||
upload_url:
|
||||
type: string
|
||||
assetBaseUrl:
|
||||
type: string
|
||||
asset_base_url:
|
||||
type: string
|
||||
siteTitle:
|
||||
type: string
|
||||
browserTitle:
|
||||
type: string
|
||||
titleLayout:
|
||||
type: string
|
||||
showSiteTitle:
|
||||
type: boolean
|
||||
maintenanceMode:
|
||||
type: boolean
|
||||
postQueue:
|
||||
type: number
|
||||
minimumTitleLength:
|
||||
type: number
|
||||
maximumTitleLength:
|
||||
type: number
|
||||
minimumPostLength:
|
||||
type: number
|
||||
maximumPostLength:
|
||||
type: number
|
||||
minimumTagsPerTopic:
|
||||
type: number
|
||||
maximumTagsPerTopic:
|
||||
type: number
|
||||
minimumTagLength:
|
||||
type: number
|
||||
undoTimeout:
|
||||
type: number
|
||||
maximumTagLength:
|
||||
type: number
|
||||
useOutgoingLinksPage:
|
||||
type: boolean
|
||||
allowGuestHandles:
|
||||
type: boolean
|
||||
allowTopicsThumbnail:
|
||||
type: boolean
|
||||
usePagination:
|
||||
type: boolean
|
||||
disableChat:
|
||||
type: boolean
|
||||
disableChatMessageEditing:
|
||||
type: boolean
|
||||
maximumChatMessageLength:
|
||||
type: number
|
||||
socketioTransports:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
socketioOrigins:
|
||||
type: string
|
||||
websocketAddress:
|
||||
type: string
|
||||
maxReconnectionAttempts:
|
||||
type: number
|
||||
reconnectionDelay:
|
||||
type: number
|
||||
topicsPerPage:
|
||||
type: number
|
||||
postsPerPage:
|
||||
type: number
|
||||
maximumFileSize:
|
||||
type: number
|
||||
theme:id:
|
||||
type: string
|
||||
theme:src:
|
||||
type: string
|
||||
defaultLang:
|
||||
type: string
|
||||
userLang:
|
||||
type: string
|
||||
loggedIn:
|
||||
type: boolean
|
||||
uid:
|
||||
type: number
|
||||
description: A user identifier
|
||||
cache-buster:
|
||||
type: string
|
||||
topicPostSort:
|
||||
type: string
|
||||
categoryTopicSort:
|
||||
type: string
|
||||
csrf_token:
|
||||
type: string
|
||||
searchEnabled:
|
||||
type: boolean
|
||||
searchDefaultInQuick:
|
||||
type: string
|
||||
disableCustomUserSkins:
|
||||
type: boolean
|
||||
bootswatchSkin:
|
||||
type: string
|
||||
defaultBootswatchSkin:
|
||||
type: string
|
||||
composer:showHelpTab:
|
||||
type: boolean
|
||||
enablePostHistory:
|
||||
type: boolean
|
||||
timeagoCutoff:
|
||||
type: number
|
||||
timeagoCodes:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
cookies:
|
||||
type: object
|
||||
properties:
|
||||
enabled:
|
||||
type: boolean
|
||||
message:
|
||||
type: string
|
||||
dismiss:
|
||||
type: string
|
||||
link:
|
||||
type: string
|
||||
link_url:
|
||||
type: string
|
||||
thumbs:
|
||||
type: object
|
||||
properties:
|
||||
size:
|
||||
type: number
|
||||
acpLang:
|
||||
type: string
|
||||
openOutgoingLinksInNewTab:
|
||||
type: boolean
|
||||
topicSearchEnabled:
|
||||
type: boolean
|
||||
hideSubCategories:
|
||||
type: boolean
|
||||
hideCategoryLastPost:
|
||||
type: boolean
|
||||
enableQuickReply:
|
||||
type: boolean
|
||||
iconBackgrounds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
description: A valid CSS colour code
|
||||
example: '#fff'
|
||||
emailPrompt:
|
||||
type: number
|
||||
useragent:
|
||||
type: object
|
||||
properties:
|
||||
isYaBrowser:
|
||||
type: boolean
|
||||
isAuthoritative:
|
||||
type: boolean
|
||||
isMobile:
|
||||
type: boolean
|
||||
isMobileNative:
|
||||
type: boolean
|
||||
isTablet:
|
||||
type: boolean
|
||||
isiPad:
|
||||
type: boolean
|
||||
isiPod:
|
||||
type: boolean
|
||||
isiPhone:
|
||||
type: boolean
|
||||
isiPhoneNative:
|
||||
type: boolean
|
||||
isAndroid:
|
||||
type: boolean
|
||||
isAndroidNative:
|
||||
type: boolean
|
||||
isBlackberry:
|
||||
type: boolean
|
||||
isOpera:
|
||||
type: boolean
|
||||
isIE:
|
||||
type: boolean
|
||||
isEdge:
|
||||
type: boolean
|
||||
isIECompatibilityMode:
|
||||
type: boolean
|
||||
isSafari:
|
||||
type: boolean
|
||||
isFirefox:
|
||||
type: boolean
|
||||
isWebkit:
|
||||
type: boolean
|
||||
isChrome:
|
||||
type: boolean
|
||||
isKonqueror:
|
||||
type: boolean
|
||||
isOmniWeb:
|
||||
type: boolean
|
||||
isSeaMonkey:
|
||||
type: boolean
|
||||
isFlock:
|
||||
type: boolean
|
||||
isAmaya:
|
||||
type: boolean
|
||||
isPhantomJS:
|
||||
type: boolean
|
||||
isEpiphany:
|
||||
type: boolean
|
||||
isDesktop:
|
||||
type: boolean
|
||||
isWindows:
|
||||
type: boolean
|
||||
isLinux:
|
||||
type: boolean
|
||||
isLinux64:
|
||||
type: boolean
|
||||
isMac:
|
||||
type: boolean
|
||||
isChromeOS:
|
||||
type: boolean
|
||||
isBada:
|
||||
type: boolean
|
||||
isSamsung:
|
||||
type: boolean
|
||||
isRaspberry:
|
||||
type: boolean
|
||||
isBot:
|
||||
type: boolean
|
||||
isCurl:
|
||||
type: boolean
|
||||
isAndroidTablet:
|
||||
type: boolean
|
||||
isWinJs:
|
||||
type: boolean
|
||||
isKindleFire:
|
||||
type: boolean
|
||||
isSilk:
|
||||
type: boolean
|
||||
isCaptive:
|
||||
type: boolean
|
||||
isSmartTV:
|
||||
type: boolean
|
||||
isUC:
|
||||
type: boolean
|
||||
isFacebook:
|
||||
type: boolean
|
||||
isAlamoFire:
|
||||
type: boolean
|
||||
isElectron:
|
||||
type: boolean
|
||||
silkAccelerated:
|
||||
type: boolean
|
||||
browser:
|
||||
type: string
|
||||
version:
|
||||
type: string
|
||||
os:
|
||||
type: string
|
||||
platform:
|
||||
type: string
|
||||
geoIp:
|
||||
type: object
|
||||
source:
|
||||
type: string
|
||||
isWechat:
|
||||
type: boolean
|
||||
composer-default:
|
||||
type: object
|
||||
fontawesome:
|
||||
type: object
|
||||
properties:
|
||||
pro:
|
||||
type: boolean
|
||||
styles:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
version:
|
||||
type: string
|
||||
@@ -94,9 +94,6 @@ get:
|
||||
uid:
|
||||
type: number
|
||||
description: A user identifier
|
||||
isACP:
|
||||
type: boolean
|
||||
description: true if admin page is being loaded, false otherwise
|
||||
cache-buster:
|
||||
type: string
|
||||
topicPostSort:
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const privileges = require('../privileges');
|
||||
const plugins = require('../plugins');
|
||||
const helpers = require('./helpers');
|
||||
const apiController = require('./api');
|
||||
|
||||
const adminController = {
|
||||
dashboard: require('./admin/dashboard'),
|
||||
@@ -55,4 +57,15 @@ adminController.routeIndex = async (req, res) => {
|
||||
return helpers.notAllowed(req, res);
|
||||
};
|
||||
|
||||
adminController.loadConfig = async function (req) {
|
||||
const config = await apiController.loadConfig(req);
|
||||
await plugins.hooks.fire('filter:config.get.admin', config);
|
||||
return config;
|
||||
};
|
||||
|
||||
adminController.getConfig = async (req, res) => {
|
||||
const config = await adminController.loadConfig(req);
|
||||
res.json(config);
|
||||
};
|
||||
|
||||
module.exports = adminController;
|
||||
|
||||
@@ -67,7 +67,6 @@ apiController.loadConfig = async function (req) {
|
||||
userLang: req.query.lang ? validator.escape(String(req.query.lang)) : (meta.config.defaultLang || 'en-GB'),
|
||||
loggedIn: !!req.user,
|
||||
uid: req.uid,
|
||||
isACP: !!(req.res && req.res.locals && req.res.locals.renderAdminHeader),
|
||||
'cache-buster': meta.config['cache-buster'] || '',
|
||||
topicPostSort: meta.config.topicPostSort || 'oldest_to_newest',
|
||||
categoryTopicSort: meta.config.categoryTopicSort || 'recently_replied',
|
||||
|
||||
@@ -10,7 +10,7 @@ const privileges = require('../privileges');
|
||||
const helpers = require('./helpers');
|
||||
|
||||
const controllers = {
|
||||
api: require('../controllers/api'),
|
||||
admin: require('../controllers/admin'),
|
||||
helpers: require('../controllers/helpers'),
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ middleware.buildHeader = helpers.try(async (req, res, next) => {
|
||||
await require('./index').applyCSRFasync(req, res);
|
||||
}
|
||||
|
||||
res.locals.config = await controllers.api.loadConfig(req);
|
||||
res.locals.config = await controllers.admin.loadConfig(req);
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ module.exports = function (theModule, ignoreKeys) {
|
||||
}
|
||||
|
||||
function wrapCallback(origFn, callbackFn) {
|
||||
return async function wrapperCallback(...args) {
|
||||
return function wrapperCallback(...args) {
|
||||
if (args.length && typeof args[args.length - 1] === 'function') {
|
||||
const cb = args.pop();
|
||||
args.push((err, res) => (res !== undefined ? cb(err, res) : cb(err)));
|
||||
|
||||
@@ -61,6 +61,7 @@ module.exports = function (app, name, middleware, controllers) {
|
||||
|
||||
|
||||
function apiRoutes(router, name, middleware, controllers) {
|
||||
router.get(`/api/${name}/config`, middleware.ensureLoggedIn, helpers.tryRoute(controllers.admin.getConfig));
|
||||
router.get(`/api/${name}/users/csv`, middleware.ensureLoggedIn, helpers.tryRoute(controllers.admin.users.getCSV));
|
||||
router.get(`/api/${name}/groups/:groupname/csv`, middleware.ensureLoggedIn, helpers.tryRoute(controllers.admin.groups.getCSV));
|
||||
router.get(`/api/${name}/analytics`, middleware.ensureLoggedIn, helpers.tryRoute(controllers.admin.dashboard.getAnalytics));
|
||||
|
||||
Reference in New Issue
Block a user