]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/plugins/plugin-helpers-builder.ts
Fix lint
[github/Chocobozzz/PeerTube.git] / server / lib / plugins / plugin-helpers-builder.ts
index bea0f89592c96d3ec7a8d5975ded5c0847849a4e..4e799b3d40164a4141373b20a5762e99e0634906 100644 (file)
@@ -1,5 +1,6 @@
 import express from 'express'
 import { join } from 'path'
+import { ffprobePromise } from '@server/helpers/ffmpeg/ffprobe-utils'
 import { buildLogger } from '@server/helpers/logger'
 import { CONFIG } from '@server/initializers/config'
 import { WEBSERVER } from '@server/initializers/constants'
@@ -82,14 +83,18 @@ function buildVideosHelpers () {
 
     removeVideo: (id: number) => {
       return sequelizeTypescript.transaction(async t => {
-        const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t)
+        const video = await VideoModel.loadFull(id, t)
 
         await video.destroy({ transaction: t })
       })
     },
 
+    ffprobe: (path: string) => {
+      return ffprobePromise(path)
+    },
+
     getFiles: async (id: number | string) => {
-      const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id)
+      const video = await VideoModel.loadFull(id)
       if (!video) return undefined
 
       const webtorrentVideoFiles = (video.VideoFiles || []).map(f => ({
@@ -173,14 +178,14 @@ function buildModerationHelpers () {
     },
 
     blacklistVideo: async (options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }) => {
-      const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID)
+      const video = await VideoModel.loadFull(options.videoIdOrUUID)
       if (!video) return
 
       await blacklistVideo(video, options.createOptions)
     },
 
     unblacklistVideo: async (options: { videoIdOrUUID: number | string }) => {
-      const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(options.videoIdOrUUID)
+      const video = await VideoModel.loadFull(options.videoIdOrUUID)
       if (!video) return
 
       const videoBlacklist = await VideoBlacklistModel.loadByVideoId(video.id)
@@ -215,6 +220,10 @@ function buildPluginRelatedHelpers (plugin: MPlugin, npmName: string) {
 
 function buildUserHelpers () {
   return {
+    loadById: (id: number) => {
+      return UserModel.loadByIdFull(id)
+    },
+
     getAuthUser: (res: express.Response) => {
       const user = res.locals.oauth?.token?.User
       if (!user) return undefined