diff options
Diffstat (limited to 'server')
-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 } = { |