1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-06 03:50:26 +02:00

Delete invalid or deleted remote videos

This commit is contained in:
Chocobozzz 2018-11-20 10:05:51 +01:00
parent f107470e50
commit 04b8c3fba6
No known key found for this signature in database
GPG key ID: 583A612D890159BE
10 changed files with 212 additions and 66 deletions

View file

@ -0,0 +1,40 @@
import * as Bull from 'bull'
import { logger } from '../../../helpers/logger'
import { fetchVideoByUrl } from '../../../helpers/video'
import { refreshVideoIfNeeded } from '../../activitypub'
export type RefreshPayload = {
videoUrl: string
type: 'video'
}
async function refreshAPObject (job: Bull.Job) {
const payload = job.data as RefreshPayload
logger.info('Processing AP refresher in job %d.', job.id)
if (payload.type === 'video') return refreshAPVideo(payload.videoUrl)
}
// ---------------------------------------------------------------------------
export {
refreshAPObject
}
// ---------------------------------------------------------------------------
async function refreshAPVideo (videoUrl: string) {
const fetchType = 'all' as 'all'
const syncParam = { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true }
const videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType)
if (videoFromDatabase) {
const refreshOptions = {
video: videoFromDatabase,
fetchedType: fetchType,
syncParam
}
await refreshVideoIfNeeded(refreshOptions)
}
}