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

Add tags to logs in AP videos

This commit is contained in:
Chocobozzz 2021-06-02 16:49:59 +02:00
parent e872632091
commit 463206948d
No known key found for this signature in database
GPG key ID: 583A612D890159BE
7 changed files with 46 additions and 25 deletions

View file

@ -1,16 +1,19 @@
import { checkUrlsSameHost } from '@server/helpers/activitypub'
import { sanitizeAndCheckVideoTorrentObject } from '@server/helpers/custom-validators/activitypub/videos'
import { logger } from '@server/helpers/logger'
import { logger, loggerTagsFactory } from '@server/helpers/logger'
import { doJSONRequest } from '@server/helpers/requests'
import { VideoObject } from '@shared/models'
const lTags = loggerTagsFactory('ap', 'video')
async function fetchRemoteVideo (videoUrl: string): Promise<{ statusCode: number, videoObject: VideoObject }> {
logger.info('Fetching remote video %s.', videoUrl)
logger.info('Fetching remote video %s.', videoUrl, lTags(videoUrl))
const { statusCode, body } = await doJSONRequest<any>(videoUrl, { activityPub: true })
if (sanitizeAndCheckVideoTorrentObject(body) === false || checkUrlsSameHost(body.id, videoUrl) !== true) {
logger.debug('Remote video JSON is not valid.', { body })
logger.debug('Remote video JSON is not valid.', { body, ...lTags(videoUrl) })
return { statusCode, videoObject: undefined }
}