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:
parent
f107470e50
commit
04b8c3fba6
10 changed files with 212 additions and 66 deletions
40
server/lib/job-queue/handlers/activitypub-refresher.ts
Normal file
40
server/lib/job-queue/handlers/activitypub-refresher.ts
Normal 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)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue