From b5206dfc455c119b0dcb897bd7144be6ea4d999d Mon Sep 17 00:00:00 2001 From: Julien Maulny Date: Tue, 3 Dec 2019 21:48:31 +0100 Subject: Fix retrieving of deleted comments when subscribing to a new instance --- .../custom-validators/activitypub/video-comments.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'server/helpers') diff --git a/server/helpers/custom-validators/activitypub/video-comments.ts b/server/helpers/custom-validators/activitypub/video-comments.ts index e04c5388f..96655c3f8 100644 --- a/server/helpers/custom-validators/activitypub/video-comments.ts +++ b/server/helpers/custom-validators/activitypub/video-comments.ts @@ -3,11 +3,28 @@ import { ACTIVITY_PUB } from '../../../initializers/constants' import { exists, isArray, isDateValid } from '../misc' import { isActivityPubUrlValid } from './misc' +function isTypeValid (comment: any): boolean { + if (comment.type === 'Note') return true + + if (comment.type === 'Tombstone' && comment.formerType === 'Note') return true + + return false +} + function sanitizeAndCheckVideoCommentObject (comment: any) { - if (!comment || comment.type !== 'Note') return false + if (!comment) return false + + if (!isTypeValid(comment)) return false normalizeComment(comment) + if (comment.type === 'Tombstone') { + return isActivityPubUrlValid(comment.id) && + isDateValid(comment.published) && + isDateValid(comment.deleted) && + isActivityPubUrlValid(comment.url) + } + return isActivityPubUrlValid(comment.id) && isCommentContentValid(comment.content) && isActivityPubUrlValid(comment.inReplyTo) && -- cgit v1.2.3