peertube-plugin-livechat/server/lib/middlewares/configuration/configuration.ts
John Livingston f97e54d499
Moderation Bot integration WIP:
* Start and stop the bot WIP
* Prosody: removing the BOSH module from the global scope (must only be present on relevant virtualhosts)
* Some refactoring
2023-09-22 16:45:06 +02:00

27 lines
903 B
TypeScript

import type { RegisterServerOptions } from '@peertube/peertube-types'
import type { Request, Response, NextFunction } from 'express'
import type { RequestPromiseHandler } from '../async'
/**
* Returns a middleware handler to check if advanced configuration is not disabled
* @param options Peertube server options
* @returns middleware function
*/
function checkConfigurationEnabledMiddleware (options: RegisterServerOptions): RequestPromiseHandler {
return async (req: Request, res: Response, next: NextFunction) => {
const settings = await options.settingsManager.getSettings([
'disable-channel-configuration'
])
if (!settings['disable-channel-configuration']) {
next()
return
}
options.peertubeHelpers.logger.info('Advanced Configuration is disabled, blocking the request.')
res.sendStatus(403)
}
}
export {
checkConfigurationEnabledMiddleware
}