aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/initializers/migrations/0405-plugin.ts40
-rw-r--r--server/lib/plugins/hooks.ts2
-rw-r--r--server/lib/plugins/plugin-manager.ts7
-rw-r--r--server/tests/plugins/action-hooks.ts2
5 files changed, 50 insertions, 3 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 1111fd97f..5329d5fab 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
14 14
15// --------------------------------------------------------------------------- 15// ---------------------------------------------------------------------------
16 16
17const LAST_MIGRATION_VERSION = 400 17const LAST_MIGRATION_VERSION = 405
18 18
19// --------------------------------------------------------------------------- 19// ---------------------------------------------------------------------------
20 20
diff --git a/server/initializers/migrations/0405-plugin.ts b/server/initializers/migrations/0405-plugin.ts
new file mode 100644
index 000000000..c55b81960
--- /dev/null
+++ b/server/initializers/migrations/0405-plugin.ts
@@ -0,0 +1,40 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction,
5 queryInterface: Sequelize.QueryInterface,
6 sequelize: Sequelize.Sequelize,
7 db: any
8}): Promise<void> {
9 {
10 const query = `
11CREATE TABLE IF NOT EXISTS "plugin"
12(
13 "id" SERIAL,
14 "name" VARCHAR(255) NOT NULL,
15 "type" INTEGER NOT NULL,
16 "version" VARCHAR(255) NOT NULL,
17 "latestVersion" VARCHAR(255),
18 "enabled" BOOLEAN NOT NULL,
19 "uninstalled" BOOLEAN NOT NULL,
20 "peertubeEngine" VARCHAR(255) NOT NULL,
21 "description" VARCHAR(255),
22 "homepage" VARCHAR(255) NOT NULL,
23 "settings" JSONB,
24 "storage" JSONB,
25 "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
26 "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
27 PRIMARY KEY ("id")
28);`
29 await utils.sequelize.query(query)
30 }
31}
32
33function down (options) {
34 throw new Error('Not implemented.')
35}
36
37export {
38 up,
39 down
40}
diff --git a/server/lib/plugins/hooks.ts b/server/lib/plugins/hooks.ts
index b694d4118..bcc8c674e 100644
--- a/server/lib/plugins/hooks.ts
+++ b/server/lib/plugins/hooks.ts
@@ -9,7 +9,7 @@ type RawFunction <U, T> = (params: U) => T
9// Helpers to run hooks 9// Helpers to run hooks
10const Hooks = { 10const Hooks = {
11 wrapObject: <T, U extends ServerFilterHookName>(result: T, hookName: U) => { 11 wrapObject: <T, U extends ServerFilterHookName>(result: T, hookName: U) => {
12 return PluginManager.Instance.runHook(hookName, result) as Promise<T> 12 return PluginManager.Instance.runHook(hookName, result)
13 }, 13 },
14 14
15 wrapPromiseFun: async <U, T, V extends ServerFilterHookName>(fun: PromiseFunction<U, T>, params: U, hookName: V) => { 15 wrapPromiseFun: async <U, T, V extends ServerFilterHookName>(fun: PromiseFunction<U, T>, params: U, hookName: V) => {
diff --git a/server/lib/plugins/plugin-manager.ts b/server/lib/plugins/plugin-manager.ts
index 6485a47c5..afc07a151 100644
--- a/server/lib/plugins/plugin-manager.ts
+++ b/server/lib/plugins/plugin-manager.ts
@@ -125,6 +125,13 @@ export class PluginManager implements ServerHook {
125 try { 125 try {
126 await this.registerPluginOrTheme(plugin) 126 await this.registerPluginOrTheme(plugin)
127 } catch (err) { 127 } catch (err) {
128 // Try to unregister the plugin
129 try {
130 await this.unregister(PluginModel.buildNpmName(plugin.name, plugin.type))
131 } catch {
132 // we don't care if we cannot unregister it
133 }
134
128 logger.error('Cannot register plugin %s, skipping.', plugin.name, { err }) 135 logger.error('Cannot register plugin %s, skipping.', plugin.name, { err })
129 } 136 }
130 } 137 }
diff --git a/server/tests/plugins/action-hooks.ts b/server/tests/plugins/action-hooks.ts
index 2a941148a..e28732cac 100644
--- a/server/tests/plugins/action-hooks.ts
+++ b/server/tests/plugins/action-hooks.ts
@@ -43,7 +43,7 @@ describe('Test plugin action hooks', function () {
43 path: getPluginTestPath() 43 path: getPluginTestPath()
44 }) 44 })
45 45
46 await killallServers([ servers[0] ]) 46 killallServers([ servers[0] ])
47 47
48 await reRunServer(servers[0]) 48 await reRunServer(servers[0])
49 }) 49 })