diff options
Diffstat (limited to 'server/lib/plugins/plugin-helpers.ts')
-rw-r--r-- | server/lib/plugins/plugin-helpers.ts | 17 |
1 files changed, 16 insertions, 1 deletions
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 | } | ||