diff options
Diffstat (limited to 'server/controllers/api/plugins.ts')
-rw-r--r-- | server/controllers/api/plugins.ts | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/server/controllers/api/plugins.ts b/server/controllers/api/plugins.ts index f8a0d19ca..1c0b5edb1 100644 --- a/server/controllers/api/plugins.ts +++ b/server/controllers/api/plugins.ts | |||
@@ -27,6 +27,7 @@ import { listAvailablePluginsFromIndex } from '../../lib/plugins/plugin-index' | |||
27 | import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model' | 27 | import { PeertubePluginIndexList } from '../../../shared/models/plugins/peertube-plugin-index-list.model' |
28 | import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model' | 28 | import { RegisteredServerSettings } from '../../../shared/models/plugins/register-server-setting.model' |
29 | import { PublicServerSetting } from '../../../shared/models/plugins/public-server.setting' | 29 | import { PublicServerSetting } from '../../../shared/models/plugins/public-server.setting' |
30 | import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes' | ||
30 | 31 | ||
31 | const pluginRouter = express.Router() | 32 | const pluginRouter = express.Router() |
32 | 33 | ||
@@ -140,7 +141,7 @@ async function installPlugin (req: express.Request, res: express.Response) { | |||
140 | return res.json(plugin.toFormattedJSON()) | 141 | return res.json(plugin.toFormattedJSON()) |
141 | } catch (err) { | 142 | } catch (err) { |
142 | logger.warn('Cannot install plugin %s.', toInstall, { err }) | 143 | logger.warn('Cannot install plugin %s.', toInstall, { err }) |
143 | return res.sendStatus(400) | 144 | return res.sendStatus(HttpStatusCode.BAD_REQUEST_400) |
144 | } | 145 | } |
145 | } | 146 | } |
146 | 147 | ||
@@ -155,7 +156,7 @@ async function updatePlugin (req: express.Request, res: express.Response) { | |||
155 | return res.json(plugin.toFormattedJSON()) | 156 | return res.json(plugin.toFormattedJSON()) |
156 | } catch (err) { | 157 | } catch (err) { |
157 | logger.warn('Cannot update plugin %s.', toUpdate, { err }) | 158 | logger.warn('Cannot update plugin %s.', toUpdate, { err }) |
158 | return res.sendStatus(400) | 159 | return res.sendStatus(HttpStatusCode.BAD_REQUEST_400) |
159 | } | 160 | } |
160 | } | 161 | } |
161 | 162 | ||
@@ -164,7 +165,7 @@ async function uninstallPlugin (req: express.Request, res: express.Response) { | |||
164 | 165 | ||
165 | await PluginManager.Instance.uninstall(body.npmName) | 166 | await PluginManager.Instance.uninstall(body.npmName) |
166 | 167 | ||
167 | return res.sendStatus(204) | 168 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) |
168 | } | 169 | } |
169 | 170 | ||
170 | function getPublicPluginSettings (req: express.Request, res: express.Response) { | 171 | function getPublicPluginSettings (req: express.Request, res: express.Response) { |
@@ -193,7 +194,7 @@ async function updatePluginSettings (req: express.Request, res: express.Response | |||
193 | 194 | ||
194 | await PluginManager.Instance.onSettingsChanged(plugin.name, plugin.settings) | 195 | await PluginManager.Instance.onSettingsChanged(plugin.name, plugin.settings) |
195 | 196 | ||
196 | return res.sendStatus(204) | 197 | return res.sendStatus(HttpStatusCode.NO_CONTENT_204) |
197 | } | 198 | } |
198 | 199 | ||
199 | async function listAvailablePlugins (req: express.Request, res: express.Response) { | 200 | async function listAvailablePlugins (req: express.Request, res: express.Response) { |
@@ -202,7 +203,7 @@ async function listAvailablePlugins (req: express.Request, res: express.Response | |||
202 | const resultList = await listAvailablePluginsFromIndex(query) | 203 | const resultList = await listAvailablePluginsFromIndex(query) |
203 | 204 | ||
204 | if (!resultList) { | 205 | if (!resultList) { |
205 | return res.status(503) | 206 | return res.status(HttpStatusCode.SERVICE_UNAVAILABLE_503) |
206 | .json({ error: 'Plugin index unavailable. Please retry later' }) | 207 | .json({ error: 'Plugin index unavailable. Please retry later' }) |
207 | .end() | 208 | .end() |
208 | } | 209 | } |