mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-04 18:29:27 +02:00
Add ability to remove a video from a plugin
This commit is contained in:
parent
1b05d82d86
commit
ab3ead3a6f
5 changed files with 68 additions and 9 deletions
|
@ -1,15 +1,18 @@
|
|||
import { PeerTubeHelpers } from '@server/typings/plugins'
|
||||
import { sequelizeTypescript } from '@server/initializers/database'
|
||||
import { buildLogger } from '@server/helpers/logger'
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
|
||||
function buildPluginHelpers (npmName: string): PeerTubeHelpers {
|
||||
const logger = buildPluginLogger(npmName)
|
||||
|
||||
const database = buildDatabaseHelpers()
|
||||
const videos = buildVideosHelpers()
|
||||
|
||||
return {
|
||||
logger,
|
||||
database
|
||||
database,
|
||||
videos
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,3 +31,15 @@ function buildDatabaseHelpers () {
|
|||
query: sequelizeTypescript.query.bind(sequelizeTypescript)
|
||||
}
|
||||
}
|
||||
|
||||
function buildVideosHelpers () {
|
||||
return {
|
||||
removeVideo: (id: number) => {
|
||||
return sequelizeTypescript.transaction(async t => {
|
||||
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t)
|
||||
|
||||
await video.destroy({ transaction: t })
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue