aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/plugins/plugin-helpers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/lib/plugins/plugin-helpers.ts')
-rw-r--r--server/lib/plugins/plugin-helpers.ts17
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 @@
1import { PeerTubeHelpers } from '@server/typings/plugins' 1import { PeerTubeHelpers } from '@server/typings/plugins'
2import { sequelizeTypescript } from '@server/initializers/database' 2import { sequelizeTypescript } from '@server/initializers/database'
3import { buildLogger } from '@server/helpers/logger' 3import { buildLogger } from '@server/helpers/logger'
4import { VideoModel } from '@server/models/video/video'
4 5
5function buildPluginHelpers (npmName: string): PeerTubeHelpers { 6function 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
35function 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}