feat(plugins): add peertubeHelpers.loadByIdOrUUIDWithFiles (#6302)

pull/6318/head
kontrollanten 2024-04-04 08:20:09 +02:00 committed by GitHub
parent cd42491cf0
commit 6f6abcabfb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 1 deletions

View File

@ -30,6 +30,13 @@ async function register ({
if (videoFromDB1.uuid !== videoFromDB2.uuid || videoFromDB2.uuid !== videoFromDB3.uuid) return if (videoFromDB1.uuid !== videoFromDB2.uuid || videoFromDB2.uuid !== videoFromDB3.uuid) return
const videoWithFiles = await peertubeHelpers.videos.loadByIdOrUUIDWithFiles(video.id)
if (videoWithFiles.getHLSPlaylist().getMasterPlaylistUrl(videoWithFiles) === null) {
logger.error('Video with files could not be loaded.')
return
}
logger.info('video from DB uuid is %s.', videoFromDB1.uuid) logger.info('video from DB uuid is %s.', videoFromDB1.uuid)
await peertubeHelpers.videos.removeVideo(video.id) await peertubeHelpers.videos.removeVideo(video.id)

View File

@ -88,6 +88,10 @@ function buildVideosHelpers () {
return VideoModel.load(id) return VideoModel.load(id)
}, },
loadByIdOrUUIDWithFiles: (id: number | string) => {
return VideoModel.loadWithFiles(id)
},
removeVideo: (id: number) => { removeVideo: (id: number) => {
return sequelizeTypescript.transaction(async t => { return sequelizeTypescript.transaction(async t => {
const video = await VideoModel.loadFull(id, t) const video = await VideoModel.loadFull(id, t)

View File

@ -17,7 +17,7 @@ import {
VideoBlacklistCreate VideoBlacklistCreate
} from '@peertube/peertube-models' } from '@peertube/peertube-models'
import { ActorModel } from '@server/models/actor/actor.js' import { ActorModel } from '@server/models/actor/actor.js'
import { MUserDefault, MVideo, MVideoThumbnail, UserNotificationModelForApi } from '../models/index.js' import { MUserDefault, MVideo, MVideoThumbnail, MVideoWithAllFiles, UserNotificationModelForApi } from '../models/index.js'
import { import {
RegisterServerAuthExternalOptions, RegisterServerAuthExternalOptions,
RegisterServerAuthExternalResult, RegisterServerAuthExternalResult,
@ -34,6 +34,7 @@ export type PeerTubeHelpers = {
videos: { videos: {
loadByUrl: (url: string) => Promise<MVideoThumbnail> loadByUrl: (url: string) => Promise<MVideoThumbnail>
loadByIdOrUUIDWithFiles: (id: number | string) => Promise<MVideoWithAllFiles>
loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail> loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail>
removeVideo: (videoId: number) => Promise<void> removeVideo: (videoId: number) => Promise<void>