aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/activitypub-refresher.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-11-20 10:05:51 +0100
committerChocobozzz <me@florianbigard.com>2018-11-20 10:44:48 +0100
commit04b8c3fba614efc3827f583096c78b08cb668470 (patch)
tree63172b40e4b029e4a14553c2fb39bd249d6cd0dd /server/lib/job-queue/handlers/activitypub-refresher.ts
parentf107470e50236e2a073f3f7dbab87c79e8364b56 (diff)
downloadPeerTube-04b8c3fba614efc3827f583096c78b08cb668470.tar.gz
PeerTube-04b8c3fba614efc3827f583096c78b08cb668470.tar.zst
PeerTube-04b8c3fba614efc3827f583096c78b08cb668470.zip
Delete invalid or deleted remote videos
Diffstat (limited to 'server/lib/job-queue/handlers/activitypub-refresher.ts')
-rw-r--r--server/lib/job-queue/handlers/activitypub-refresher.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-refresher.ts b/server/lib/job-queue/handlers/activitypub-refresher.ts
new file mode 100644
index 000000000..7752b3b40
--- /dev/null
+++ b/server/lib/job-queue/handlers/activitypub-refresher.ts
@@ -0,0 +1,40 @@
1import * as Bull from 'bull'
2import { logger } from '../../../helpers/logger'
3import { fetchVideoByUrl } from '../../../helpers/video'
4import { refreshVideoIfNeeded } from '../../activitypub'
5
6export type RefreshPayload = {
7 videoUrl: string
8 type: 'video'
9}
10
11async function refreshAPObject (job: Bull.Job) {
12 const payload = job.data as RefreshPayload
13 logger.info('Processing AP refresher in job %d.', job.id)
14
15 if (payload.type === 'video') return refreshAPVideo(payload.videoUrl)
16}
17
18// ---------------------------------------------------------------------------
19
20export {
21 refreshAPObject
22}
23
24// ---------------------------------------------------------------------------
25
26async function refreshAPVideo (videoUrl: string) {
27 const fetchType = 'all' as 'all'
28 const syncParam = { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true }
29
30 const videoFromDatabase = await fetchVideoByUrl(videoUrl, fetchType)
31 if (videoFromDatabase) {
32 const refreshOptions = {
33 video: videoFromDatabase,
34 fetchedType: fetchType,
35 syncParam
36 }
37
38 await refreshVideoIfNeeded(refreshOptions)
39 }
40}