aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-05-21 09:34:02 +0200
committerChocobozzz <me@florianbigard.com>2019-05-21 09:34:02 +0200
commitfd822c1c699fb89bb1c3218e047e1d842bc1ba1a (patch)
tree4f7e81261f2dc07aa75a83e97f25da1f11e146ea /server/helpers
parentb5bfadf0b5365481179936fd3058134fd8be8e18 (diff)
parent4550872bcc8f9ef46183463c7b7b74a90cb6d17c (diff)
downloadPeerTube-fd822c1c699fb89bb1c3218e047e1d842bc1ba1a.tar.gz
PeerTube-fd822c1c699fb89bb1c3218e047e1d842bc1ba1a.tar.zst
PeerTube-fd822c1c699fb89bb1c3218e047e1d842bc1ba1a.zip
Merge branch 'release/v1.3.0' into develop
Diffstat (limited to 'server/helpers')
-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 } = {