aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/job-queue/handlers/activitypub-cleaner.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-03-08 14:24:11 +0100
committerChocobozzz <me@florianbigard.com>2021-03-24 18:18:40 +0100
commitdb4b15f21fbf4e33434e930ffc7fb768cdcf9d42 (patch)
tree418117b84a5c2ee578c210288b698d155422d608 /server/lib/job-queue/handlers/activitypub-cleaner.ts
parent71926aae0762facb25243f27eaf45933b5a37353 (diff)
downloadPeerTube-db4b15f21fbf4e33434e930ffc7fb768cdcf9d42.tar.gz
PeerTube-db4b15f21fbf4e33434e930ffc7fb768cdcf9d42.tar.zst
PeerTube-db4b15f21fbf4e33434e930ffc7fb768cdcf9d42.zip
Use got instead of request
Diffstat (limited to 'server/lib/job-queue/handlers/activitypub-cleaner.ts')
-rw-r--r--server/lib/job-queue/handlers/activitypub-cleaner.ts11
1 files changed, 3 insertions, 8 deletions
diff --git a/server/lib/job-queue/handlers/activitypub-cleaner.ts b/server/lib/job-queue/handlers/activitypub-cleaner.ts
index 0e75b0a6e..9dcc778fa 100644
--- a/server/lib/job-queue/handlers/activitypub-cleaner.ts
+++ b/server/lib/job-queue/handlers/activitypub-cleaner.ts
@@ -7,7 +7,7 @@ import {
7 isLikeActivityValid 7 isLikeActivityValid
8} from '@server/helpers/custom-validators/activitypub/activity' 8} from '@server/helpers/custom-validators/activitypub/activity'
9import { sanitizeAndCheckVideoCommentObject } from '@server/helpers/custom-validators/activitypub/video-comments' 9import { sanitizeAndCheckVideoCommentObject } from '@server/helpers/custom-validators/activitypub/video-comments'
10import { doRequest } from '@server/helpers/requests' 10import { doJSONRequest } from '@server/helpers/requests'
11import { AP_CLEANER_CONCURRENCY } from '@server/initializers/constants' 11import { AP_CLEANER_CONCURRENCY } from '@server/initializers/constants'
12import { VideoModel } from '@server/models/video/video' 12import { VideoModel } from '@server/models/video/video'
13import { VideoCommentModel } from '@server/models/video/video-comment' 13import { VideoCommentModel } from '@server/models/video/video-comment'
@@ -81,15 +81,10 @@ async function updateObjectIfNeeded <T> (
81 updater: (url: string, newUrl: string) => Promise<T>, 81 updater: (url: string, newUrl: string) => Promise<T>,
82 deleter: (url: string) => Promise<T> 82 deleter: (url: string) => Promise<T>
83): Promise<{ data: T, status: 'deleted' | 'updated' } | null> { 83): Promise<{ data: T, status: 'deleted' | 'updated' } | null> {
84 // Fetch url 84 const { statusCode, body } = await doJSONRequest<any>(url, { activityPub: true })
85 const { response, body } = await doRequest<any>({
86 uri: url,
87 json: true,
88 activityPub: true
89 })
90 85
91 // Does not exist anymore, remove entry 86 // Does not exist anymore, remove entry
92 if (response.statusCode === HttpStatusCode.NOT_FOUND_404) { 87 if (statusCode === HttpStatusCode.NOT_FOUND_404) {
93 logger.info('Removing remote AP object %s.', url) 88 logger.info('Removing remote AP object %s.', url)
94 const data = await deleter(url) 89 const data = await deleter(url)
95 90