mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-03 17:59:37 +02:00
Add public settings endpoint
This commit is contained in:
parent
23bdacf8ec
commit
ba211e7386
10 changed files with 94 additions and 28 deletions
|
@ -26,6 +26,7 @@ import { logger } from '../../helpers/logger'
|
|||
import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index'
|
||||
import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model'
|
||||
import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model'
|
||||
import { PublicServerSetting } from '../../../shared/models/plugins/public-server.setting'
|
||||
|
||||
const pluginRouter = express.Router()
|
||||
|
||||
|
@ -51,13 +52,6 @@ pluginRouter.get('/',
|
|||
asyncMiddleware(listPlugins)
|
||||
)
|
||||
|
||||
pluginRouter.get('/:npmName',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
asyncMiddleware(existingPluginValidator),
|
||||
getPlugin
|
||||
)
|
||||
|
||||
pluginRouter.get('/:npmName/registered-settings',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
|
@ -65,6 +59,11 @@ pluginRouter.get('/:npmName/registered-settings',
|
|||
getPluginRegisteredSettings
|
||||
)
|
||||
|
||||
pluginRouter.get('/:npmName/public-settings',
|
||||
asyncMiddleware(existingPluginValidator),
|
||||
getPublicPluginSettings
|
||||
)
|
||||
|
||||
pluginRouter.put('/:npmName/settings',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
|
@ -73,6 +72,13 @@ pluginRouter.put('/:npmName/settings',
|
|||
asyncMiddleware(updatePluginSettings)
|
||||
)
|
||||
|
||||
pluginRouter.get('/:npmName',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
asyncMiddleware(existingPluginValidator),
|
||||
getPlugin
|
||||
)
|
||||
|
||||
pluginRouter.post('/install',
|
||||
authenticate,
|
||||
ensureUserHasRight(UserRight.MANAGE_PLUGINS),
|
||||
|
@ -161,10 +167,20 @@ async function uninstallPlugin (req: express.Request, res: express.Response) {
|
|||
return res.sendStatus(204)
|
||||
}
|
||||
|
||||
function getPluginRegisteredSettings (req: express.Request, res: express.Response) {
|
||||
const settings = PluginManager.Instance.getRegisteredSettings(req.params.npmName)
|
||||
function getPublicPluginSettings (req: express.Request, res: express.Response) {
|
||||
const plugin = res.locals.plugin
|
||||
const registeredSettings = PluginManager.Instance.getRegisteredSettings(req.params.npmName)
|
||||
const publicSettings = plugin.getPublicSettings(registeredSettings)
|
||||
|
||||
const json: RegisteredServerSettings = { settings }
|
||||
const json: PublicServerSetting = { publicSettings }
|
||||
|
||||
return res.json(json)
|
||||
}
|
||||
|
||||
function getPluginRegisteredSettings (req: express.Request, res: express.Response) {
|
||||
const registeredSettings = PluginManager.Instance.getRegisteredSettings(req.params.npmName)
|
||||
|
||||
const json: RegisteredServerSettings = { registeredSettings }
|
||||
|
||||
return res.json(json)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue