diff options
Diffstat (limited to 'server/lib/plugins')
-rw-r--r-- | server/lib/plugins/hooks.ts | 2 | ||||
-rw-r--r-- | server/lib/plugins/plugin-helpers.ts | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/server/lib/plugins/hooks.ts b/server/lib/plugins/hooks.ts index bcc8c674e..aa92f03cc 100644 --- a/server/lib/plugins/hooks.ts +++ b/server/lib/plugins/hooks.ts | |||
@@ -25,7 +25,7 @@ const Hooks = { | |||
25 | }, | 25 | }, |
26 | 26 | ||
27 | runAction: <T, U extends ServerActionHookName>(hookName: U, params?: T) => { | 27 | runAction: <T, U extends ServerActionHookName>(hookName: U, params?: T) => { |
28 | PluginManager.Instance.runHook(hookName, params) | 28 | PluginManager.Instance.runHook(hookName, undefined, params) |
29 | .catch(err => logger.error('Fatal hook error.', { err })) | 29 | .catch(err => logger.error('Fatal hook error.', { err })) |
30 | } | 30 | } |
31 | } | 31 | } |
diff --git a/server/lib/plugins/plugin-helpers.ts b/server/lib/plugins/plugin-helpers.ts index a1493c7df..e91beffba 100644 --- a/server/lib/plugins/plugin-helpers.ts +++ b/server/lib/plugins/plugin-helpers.ts | |||
@@ -1,15 +1,18 @@ | |||
1 | import { PeerTubeHelpers } from '@server/typings/plugins' | 1 | import { PeerTubeHelpers } from '@server/typings/plugins' |
2 | import { sequelizeTypescript } from '@server/initializers/database' | 2 | import { sequelizeTypescript } from '@server/initializers/database' |
3 | import { buildLogger } from '@server/helpers/logger' | 3 | import { buildLogger } from '@server/helpers/logger' |
4 | import { VideoModel } from '@server/models/video/video' | ||
4 | 5 | ||
5 | function buildPluginHelpers (npmName: string): PeerTubeHelpers { | 6 | function buildPluginHelpers (npmName: string): PeerTubeHelpers { |
6 | const logger = buildPluginLogger(npmName) | 7 | const logger = buildPluginLogger(npmName) |
7 | 8 | ||
8 | const database = buildDatabaseHelpers() | 9 | const database = buildDatabaseHelpers() |
10 | const videos = buildVideosHelpers() | ||
9 | 11 | ||
10 | return { | 12 | return { |
11 | logger, | 13 | logger, |
12 | database | 14 | database, |
15 | videos | ||
13 | } | 16 | } |
14 | } | 17 | } |
15 | 18 | ||
@@ -28,3 +31,15 @@ function buildDatabaseHelpers () { | |||
28 | query: sequelizeTypescript.query.bind(sequelizeTypescript) | 31 | query: sequelizeTypescript.query.bind(sequelizeTypescript) |
29 | } | 32 | } |
30 | } | 33 | } |
34 | |||
35 | function buildVideosHelpers () { | ||
36 | return { | ||
37 | removeVideo: (id: number) => { | ||
38 | return sequelizeTypescript.transaction(async t => { | ||
39 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t) | ||
40 | |||
41 | await video.destroy({ transaction: t }) | ||
42 | }) | ||
43 | } | ||
44 | } | ||
45 | } | ||