aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-21 09:31:53 +0200
committerChocobozzz <me@florianbigard.com>2019-05-21 09:31:53 +0200
commit4550872bcc8f9ef46183463c7b7b74a90cb6d17c (patch)
tree9cfe8d3b25a9845fb2d67b61f970e092a5a6ce39 /server
parentb767c4a74aa5ce44c7b6a89962cb153ecb3ace07 (diff)
downloadPeerTube-4550872bcc8f9ef46183463c7b7b74a90cb6d17c.tar.gz
PeerTube-4550872bcc8f9ef46183463c7b7b74a90cb6d17c.tar.zst
PeerTube-4550872bcc8f9ef46183463c7b7b74a90cb6d17c.zip
Relax activity validation
Diffstat (limited to 'server')
-rw-r--r--server/helpers/custom-validators/activitypub/activity.ts25
1 files changed, 13 insertions, 12 deletions
diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts
index e0d170d9d..f68c76cdc 100644
--- a/server/helpers/custom-validators/activitypub/activity.ts
+++ b/server/helpers/custom-validators/activitypub/activity.ts
@@ -12,18 +12,19 @@ import { isFlagActivityValid } from './flag'
12import { isPlaylistObjectValid } from './playlist' 12import { isPlaylistObjectValid } from './playlist'
13 13
14function isRootActivityValid (activity: any) { 14function isRootActivityValid (activity: any) {
15 return Array.isArray(activity['@context']) && ( 15 return isCollection(activity) || isActivity(activity)
16 ( 16}
17 (activity.type === 'Collection' || activity.type === 'OrderedCollection') && 17
18 validator.isInt(activity.totalItems, { min: 0 }) && 18function isCollection (activity: any) {
19 Array.isArray(activity.items) 19 return (activity.type === 'Collection' || activity.type === 'OrderedCollection') &&
20 ) || 20 validator.isInt(activity.totalItems, { min: 0 }) &&
21 ( 21 Array.isArray(activity.items)
22 isActivityPubUrlValid(activity.id) && 22}
23 exists(activity.actor) && 23
24 (isActivityPubUrlValid(activity.actor) || isActivityPubUrlValid(activity.actor.id)) 24function isActivity (activity: any) {
25 ) 25 return isActivityPubUrlValid(activity.id) &&
26 ) 26 exists(activity.actor) &&
27 (isActivityPubUrlValid(activity.actor) || isActivityPubUrlValid(activity.actor.id))
27} 28}
28 29
29const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean } = { 30const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean } = {