aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
authorJulien Maulny <julien.maulny@protonmail.com>2019-12-03 21:48:31 +0100
committerChocobozzz <chocobozzz@cpy.re>2019-12-04 09:36:45 +0100
commitb5206dfc455c119b0dcb897bd7144be6ea4d999d (patch)
treed79387081b80c0bbee38beee00f6560a599a99a9 /server/helpers/custom-validators
parent69222afac8f8c41d90295b33f0695bbff352851e (diff)
downloadPeerTube-b5206dfc455c119b0dcb897bd7144be6ea4d999d.tar.gz
PeerTube-b5206dfc455c119b0dcb897bd7144be6ea4d999d.tar.zst
PeerTube-b5206dfc455c119b0dcb897bd7144be6ea4d999d.zip
Fix retrieving of deleted comments when subscribing to a new instance
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/activitypub/video-comments.ts19
1 files changed, 18 insertions, 1 deletions
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'
3import { exists, isArray, isDateValid } from '../misc' 3import { exists, isArray, isDateValid } from '../misc'
4import { isActivityPubUrlValid } from './misc' 4import { isActivityPubUrlValid } from './misc'
5 5
6function isTypeValid (comment: any): boolean {
7 if (comment.type === 'Note') return true
8
9 if (comment.type === 'Tombstone' && comment.formerType === 'Note') return true
10
11 return false
12}
13
6function sanitizeAndCheckVideoCommentObject (comment: any) { 14function sanitizeAndCheckVideoCommentObject (comment: any) {
7 if (!comment || comment.type !== 'Note') return false 15 if (!comment) return false
16
17 if (!isTypeValid(comment)) return false
8 18
9 normalizeComment(comment) 19 normalizeComment(comment)
10 20
21 if (comment.type === 'Tombstone') {
22 return isActivityPubUrlValid(comment.id) &&
23 isDateValid(comment.published) &&
24 isDateValid(comment.deleted) &&
25 isActivityPubUrlValid(comment.url)
26 }
27
11 return isActivityPubUrlValid(comment.id) && 28 return isActivityPubUrlValid(comment.id) &&
12 isCommentContentValid(comment.content) && 29 isCommentContentValid(comment.content) &&
13 isActivityPubUrlValid(comment.inReplyTo) && 30 isActivityPubUrlValid(comment.inReplyTo) &&