diff options
Diffstat (limited to 'server/helpers/custom-validators/activitypub/misc.ts')
-rw-r--r-- | server/helpers/custom-validators/activitypub/misc.ts | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/activitypub/misc.ts b/server/helpers/custom-validators/activitypub/misc.ts index 806d33483..f049f5a8c 100644 --- a/server/helpers/custom-validators/activitypub/misc.ts +++ b/server/helpers/custom-validators/activitypub/misc.ts | |||
@@ -12,6 +12,16 @@ function isActivityPubUrlValid (url: string) { | |||
12 | return exists(url) && validator.isURL(url, isURLOptions) | 12 | return exists(url) && validator.isURL(url, isURLOptions) |
13 | } | 13 | } |
14 | 14 | ||
15 | function isBaseActivityValid (activity: any, type: string) { | ||
16 | return Array.isArray(activity['@context']) && | ||
17 | activity.type === type && | ||
18 | validator.isURL(activity.id) && | ||
19 | validator.isURL(activity.actor) && | ||
20 | Array.isArray(activity.to) && | ||
21 | activity.to.every(t => validator.isURL(t)) | ||
22 | } | ||
23 | |||
15 | export { | 24 | export { |
16 | isActivityPubUrlValid | 25 | isActivityPubUrlValid, |
26 | isBaseActivityValid | ||
17 | } | 27 | } |