X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fvideo-comments.ts;h=fd03710c2c4aea8aa8584f539886007bdfb14416;hb=4a9e71c2b1ef57de01cd04984348b3957ebbc21d;hp=b33ae27b19ddcc7a4d51b2bcd5a6c45543d5671d;hpb=6502c3d43e512e968ad49f5a3bc9abc302471e18;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts index b33ae27b1..fd03710c2 100644 --- a/server/lib/activitypub/video-comments.ts +++ b/server/lib/activitypub/video-comments.ts @@ -1,5 +1,5 @@ import { VideoCommentObject } from '../../../shared/models/activitypub/objects/video-comment-object' -import { isVideoCommentObjectValid } from '../../helpers/custom-validators/activitypub/video-comments' +import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments' import { logger } from '../../helpers/logger' import { doRequest } from '../../helpers/requests' import { ACTIVITY_PUB } from '../../initializers' @@ -37,7 +37,7 @@ async function videoCommentActivityObjectToDBAttributes (video: VideoModel, acto } } -async function addVideoComments (instance: VideoModel, commentUrls: string[]) { +async function addVideoComments (commentUrls: string[], instance: VideoModel) { for (const commentUrl of commentUrls) { await addVideoComment(instance, commentUrl) } @@ -52,7 +52,7 @@ async function addVideoComment (videoInstance: VideoModel, commentUrl: string) { activityPub: true }) - if (isVideoCommentObjectValid(body) === false) { + if (sanitizeAndCheckVideoCommentObject(body) === false) { logger.debug('Remote video comment JSON is not valid.', { body }) return undefined } @@ -111,7 +111,7 @@ async function resolveThread (url: string, comments: VideoCommentModel[] = []) { return { video, parents: comments } } catch (err) { - logger.debug('Cannot get or create account and video and channel for reply %s, fetch comment', url, err) + logger.debug('Cannot get or create account and video and channel for reply %s, fetch comment', url, { err }) if (comments.length > ACTIVITY_PUB.MAX_RECURSION_COMMENTS) { throw new Error('Recursion limit reached when resolving a thread') @@ -123,7 +123,7 @@ async function resolveThread (url: string, comments: VideoCommentModel[] = []) { activityPub: true }) - if (isVideoCommentObjectValid(body) === false) { + if (sanitizeAndCheckVideoCommentObject(body) === false) { throw new Error('Remote video comment JSON is not valid :' + JSON.stringify(body)) }