aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/plugins.ts32
1 files changed, 24 insertions, 8 deletions
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts
index 86384ee27..6b7562fd3 100644
--- a/server/controllers/api/plugins.ts
+++ b/server/controllers/api/plugins.ts
@@ -26,6 +26,7 @@ import { logger } from '../../helpers/logger'
26import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index' 26import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index'
27import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model' 27import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model'
28import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model' 28import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model'
29import { PublicServerSetting } from '../../../shared/models/plugins/public-server.setting'
29 30
30const pluginRouter = express.Router() 31const pluginRouter = express.Router()
31 32
@@ -51,18 +52,16 @@ pluginRouter.get('/',
51 asyncMiddleware(listPlugins) 52 asyncMiddleware(listPlugins)
52) 53)
53 54
54pluginRouter.get('/:npmName', 55pluginRouter.get('/:npmName/registered-settings',
55 authenticate, 56 authenticate,
56 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 57 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
57 asyncMiddleware(existingPluginValidator), 58 asyncMiddleware(existingPluginValidator),
58 getPlugin 59 getPluginRegisteredSettings
59) 60)
60 61
61pluginRouter.get('/:npmName/registered-settings', 62pluginRouter.get('/:npmName/public-settings',
62 authenticate,
63 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
64 asyncMiddleware(existingPluginValidator), 63 asyncMiddleware(existingPluginValidator),
65 getPluginRegisteredSettings 64 getPublicPluginSettings
66) 65)
67 66
68pluginRouter.put('/:npmName/settings', 67pluginRouter.put('/:npmName/settings',
@@ -73,6 +72,13 @@ pluginRouter.put('/:npmName/settings',
73 asyncMiddleware(updatePluginSettings) 72 asyncMiddleware(updatePluginSettings)
74) 73)
75 74
75pluginRouter.get('/:npmName',
76 authenticate,
77 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
78 asyncMiddleware(existingPluginValidator),
79 getPlugin
80)
81
76pluginRouter.post('/install', 82pluginRouter.post('/install',
77 authenticate, 83 authenticate,
78 ensureUserHasRight(UserRight.MANAGE_PLUGINS), 84 ensureUserHasRight(UserRight.MANAGE_PLUGINS),
@@ -161,10 +167,20 @@ async function uninstallPlugin (req: express.Request, res: express.Response) {
161 return res.sendStatus(204) 167 return res.sendStatus(204)
162} 168}
163 169
170function getPublicPluginSettings (req: express.Request, res: express.Response) {
171 const plugin = res.locals.plugin
172 const registeredSettings = PluginManager.Instance.getRegisteredSettings(req.params.npmName)
173 const publicSettings = plugin.getPublicSettings(registeredSettings)
174
175 const json: PublicServerSetting = { publicSettings }
176
177 return res.json(json)
178}
179
164function getPluginRegisteredSettings (req: express.Request, res: express.Response) { 180function getPluginRegisteredSettings (req: express.Request, res: express.Response) {
165 const settings = PluginManager.Instance.getRegisteredSettings(req.params.npmName) 181 const registeredSettings = PluginManager.Instance.getRegisteredSettings(req.params.npmName)
166 182
167 const json: RegisteredServerSettings = { settings } 183 const json: RegisteredServerSettings = { registeredSettings }
168 184
169 return res.json(json) 185 return res.json(json)
170} 186}