]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/controllers/api/plugins.ts
Set actor preferred name case insensitive
[github/Chocobozzz/PeerTube.git] / server / controllers / api / plugins.ts
index 4b213c2461fad7d106c6bf736ced1f4c4e5aa09e..e85fd6e116207c8642ff8bcec92b50f244ff196d 100644 (file)
@@ -1,4 +1,4 @@
-import * as express from 'express'
+import express from 'express'
 import { logger } from '@server/helpers/logger'
 import { getFormattedObjects } from '@server/helpers/utils'
 import { listAvailablePluginsFromIndex } from '@server/lib/plugins/plugin-index'
@@ -23,8 +23,8 @@ import {
   updatePluginSettingsValidator
 } from '@server/middlewares/validators/plugins'
 import { PluginModel } from '@server/models/server/plugin'
-import { HttpStatusCode } from '@shared/models'
 import {
+  HttpStatusCode,
   InstallOrUpdatePlugin,
   ManagePlugin,
   PeertubePluginIndexList,
@@ -144,8 +144,13 @@ async function installPlugin (req: express.Request, res: express.Response) {
 
   const fromDisk = !!body.path
   const toInstall = body.npmName || body.path
+
+  const pluginVersion = body.pluginVersion && body.npmName
+    ? body.pluginVersion
+    : undefined
+
   try {
-    const plugin = await PluginManager.Instance.install(toInstall, undefined, fromDisk)
+    const plugin = await PluginManager.Instance.install({ toInstall, version: pluginVersion, fromDisk })
 
     return res.json(plugin.toFormattedJSON())
   } catch (err) {
@@ -172,7 +177,7 @@ async function updatePlugin (req: express.Request, res: express.Response) {
 async function uninstallPlugin (req: express.Request, res: express.Response) {
   const body: ManagePlugin = req.body
 
-  await PluginManager.Instance.uninstall(body.npmName)
+  await PluginManager.Instance.uninstall({ npmName: body.npmName })
 
   return res.status(HttpStatusCode.NO_CONTENT_204).end()
 }