1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Use got instead of request

This commit is contained in:
Chocobozzz 2021-03-08 14:24:11 +01:00
parent 71926aae07
commit db4b15f21f
No known key found for this signature in database
GPG key ID: 583A612D890159BE
32 changed files with 346 additions and 328 deletions

View file

@ -7,7 +7,7 @@ import {
isLikeActivityValid
} from '@server/helpers/custom-validators/activitypub/activity'
import { sanitizeAndCheckVideoCommentObject } from '@server/helpers/custom-validators/activitypub/video-comments'
import { doRequest } from '@server/helpers/requests'
import { doJSONRequest } from '@server/helpers/requests'
import { AP_CLEANER_CONCURRENCY } from '@server/initializers/constants'
import { VideoModel } from '@server/models/video/video'
import { VideoCommentModel } from '@server/models/video/video-comment'
@ -81,15 +81,10 @@ async function updateObjectIfNeeded <T> (
updater: (url: string, newUrl: string) => Promise<T>,
deleter: (url: string) => Promise<T>
): Promise<{ data: T, status: 'deleted' | 'updated' } | null> {
// Fetch url
const { response, body } = await doRequest<any>({
uri: url,
json: true,
activityPub: true
})
const { statusCode, body } = await doJSONRequest<any>(url, { activityPub: true })
// Does not exist anymore, remove entry
if (response.statusCode === HttpStatusCode.NOT_FOUND_404) {
if (statusCode === HttpStatusCode.NOT_FOUND_404) {
logger.info('Removing remote AP object %s.', url)
const data = await deleter(url)