diff options
author | Chocobozzz <me@florianbigard.com> | 2019-05-21 09:31:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-05-21 09:31:53 +0200 |
commit | 4550872bcc8f9ef46183463c7b7b74a90cb6d17c (patch) | |
tree | 9cfe8d3b25a9845fb2d67b61f970e092a5a6ce39 /server/helpers | |
parent | b767c4a74aa5ce44c7b6a89962cb153ecb3ace07 (diff) | |
download | PeerTube-4550872bcc8f9ef46183463c7b7b74a90cb6d17c.tar.gz PeerTube-4550872bcc8f9ef46183463c7b7b74a90cb6d17c.tar.zst PeerTube-4550872bcc8f9ef46183463c7b7b74a90cb6d17c.zip |
Relax activity validation
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/activitypub/activity.ts | 25 |
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' | |||
12 | import { isPlaylistObjectValid } from './playlist' | 12 | import { isPlaylistObjectValid } from './playlist' |
13 | 13 | ||
14 | function isRootActivityValid (activity: any) { | 14 | function 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 }) && | 18 | function 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)) | 24 | function 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 | ||
29 | const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean } = { | 30 | const activityCheckers: { [ P in ActivityType ]: (activity: Activity) => boolean } = { |