aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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 } = {