diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/custom-validators/activitypub/actor.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index 4e9aabf0e..ec4dd6f96 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts | |||
@@ -6,7 +6,12 @@ import { isHostValid } from '../servers' | |||
6 | import { peertubeTruncate } from '@server/helpers/core-utils' | 6 | import { peertubeTruncate } from '@server/helpers/core-utils' |
7 | 7 | ||
8 | function isActorEndpointsObjectValid (endpointObject: any) { | 8 | function isActorEndpointsObjectValid (endpointObject: any) { |
9 | return isActivityPubUrlValid(endpointObject.sharedInbox) | 9 | if (endpointObject && endpointObject.sharedInbox) { |
10 | return isActivityPubUrlValid(endpointObject.sharedInbox) | ||
11 | } | ||
12 | |||
13 | // Shared inbox is optional | ||
14 | return true | ||
10 | } | 15 | } |
11 | 16 | ||
12 | function isActorPublicKeyObjectValid (publicKeyObject: any) { | 17 | function isActorPublicKeyObjectValid (publicKeyObject: any) { |
@@ -16,7 +21,7 @@ function isActorPublicKeyObjectValid (publicKeyObject: any) { | |||
16 | } | 21 | } |
17 | 22 | ||
18 | function isActorTypeValid (type: string) { | 23 | function isActorTypeValid (type: string) { |
19 | return type === 'Person' || type === 'Application' || type === 'Group' | 24 | return type === 'Person' || type === 'Application' || type === 'Group' || type === 'Service' || type === 'Organization' |
20 | } | 25 | } |
21 | 26 | ||
22 | function isActorPublicKeyValid (publicKey: string) { | 27 | function isActorPublicKeyValid (publicKey: string) { |
@@ -81,9 +86,11 @@ function sanitizeAndCheckActorObject (object: any) { | |||
81 | } | 86 | } |
82 | 87 | ||
83 | function normalizeActor (actor: any) { | 88 | function normalizeActor (actor: any) { |
84 | if (!actor || !actor.url) return | 89 | if (!actor) return |
85 | 90 | ||
86 | if (typeof actor.url !== 'string') { | 91 | if (!actor.url) { |
92 | actor.url = actor.id | ||
93 | } else if (typeof actor.url !== 'string') { | ||
87 | actor.url = actor.url.href || actor.url.url | 94 | actor.url = actor.url.href || actor.url.url |
88 | } | 95 | } |
89 | 96 | ||