From 766f2cb76a56a7fb54cfc417f769797a2cc5636a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 13 Aug 2024 09:11:52 +0200 Subject: [PATCH] Relax federation logs --- server/core/lib/activitypub/share.ts | 8 +++++++- server/core/lib/activitypub/video-comments.ts | 9 +++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/server/core/lib/activitypub/share.ts b/server/core/lib/activitypub/share.ts index b62b67574..5edc2c708 100644 --- a/server/core/lib/activitypub/share.ts +++ b/server/core/lib/activitypub/share.ts @@ -9,6 +9,7 @@ import { fetchAP, getAPId } from './activity.js' import { getOrCreateAPActor } from './actors/index.js' import { sendUndoAnnounce, sendVideoAnnounce } from './send/index.js' import { checkUrlsSameHost, getLocalVideoAnnounceActivityPubUrl } from './url.js' +import { HttpStatusCode } from '@peertube/peertube-models' const lTags = loggerTagsFactory('share') @@ -32,7 +33,12 @@ export async function addVideoShares (shareUrls: string[], video: MVideoId) { try { await addVideoShare(shareUrl, video) } catch (err) { - logger.warn('Cannot add share %s.', shareUrl, { err }) + if (err.statusCode === HttpStatusCode.NOT_FOUND_404 || err.statusCode === HttpStatusCode.GONE_410) { + logger.debug(`Cannot add share ${shareUrl} that does not exist anymore`, { err }) + return + } + + logger.info(`Cannot add share ${shareUrl}`, { err }) } }, { concurrency: CRAWL_REQUEST_CONCURRENCY }) } diff --git a/server/core/lib/activitypub/video-comments.ts b/server/core/lib/activitypub/video-comments.ts index 067f8e911..c481af555 100644 --- a/server/core/lib/activitypub/video-comments.ts +++ b/server/core/lib/activitypub/video-comments.ts @@ -1,4 +1,4 @@ -import { VideoCommentPolicy } from '@peertube/peertube-models' +import { HttpStatusCode, VideoCommentPolicy } from '@peertube/peertube-models' import Bluebird from 'bluebird' import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments.js' import { logger } from '../../helpers/logger.js' @@ -34,7 +34,12 @@ export async function addVideoComments (commentUrls: string[]) { try { await resolveThread({ url: commentUrl, isVideo: false }) } catch (err) { - logger.warn('Cannot resolve thread %s.', commentUrl, { err }) + if (err.statusCode === HttpStatusCode.NOT_FOUND_404 || err.statusCode === HttpStatusCode.GONE_410) { + logger.debug(`Cannot resolve thread ${commentUrl} that does not exist anymore`, { err }) + return + } + + logger.info(`Cannot resolve thread ${commentUrl}`, { err }) } }, { concurrency: CRAWL_REQUEST_CONCURRENCY }) }