diff options
author | Julien Maulny <julien.maulny@protonmail.com> | 2019-12-03 21:48:31 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-12-04 09:36:45 +0100 |
commit | b5206dfc455c119b0dcb897bd7144be6ea4d999d (patch) | |
tree | d79387081b80c0bbee38beee00f6560a599a99a9 /server/helpers/custom-validators | |
parent | 69222afac8f8c41d90295b33f0695bbff352851e (diff) | |
download | PeerTube-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.ts | 19 |
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' | |||
3 | import { exists, isArray, isDateValid } from '../misc' | 3 | import { exists, isArray, isDateValid } from '../misc' |
4 | import { isActivityPubUrlValid } from './misc' | 4 | import { isActivityPubUrlValid } from './misc' |
5 | 5 | ||
6 | function 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 | |||
6 | function sanitizeAndCheckVideoCommentObject (comment: any) { | 14 | function 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) && |