diff options
author | Chocobozzz <me@florianbigard.com> | 2020-04-09 11:35:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-04-09 11:37:44 +0200 |
commit | ab3ead3a6f080e6768b898e699c8de92703d93c6 (patch) | |
tree | d335ad83d47341b43ca842c319f21eaefdcc78e4 /server/lib | |
parent | 1b05d82d861f42c27766e9f24d8d55e68b0cf098 (diff) | |
download | PeerTube-ab3ead3a6f080e6768b898e699c8de92703d93c6.tar.gz PeerTube-ab3ead3a6f080e6768b898e699c8de92703d93c6.tar.zst PeerTube-ab3ead3a6f080e6768b898e699c8de92703d93c6.zip |
Add ability to remove a video from a plugin
Diffstat (limited to 'server/lib')
-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 | } | ||