aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/custom-validators
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/custom-validators')
-rw-r--r--server/helpers/custom-validators/activitypub/actor.ts15
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'
6import { peertubeTruncate } from '@server/helpers/core-utils' 6import { peertubeTruncate } from '@server/helpers/core-utils'
7 7
8function isActorEndpointsObjectValid (endpointObject: any) { 8function 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
12function isActorPublicKeyObjectValid (publicKeyObject: any) { 17function isActorPublicKeyObjectValid (publicKeyObject: any) {
@@ -16,7 +21,7 @@ function isActorPublicKeyObjectValid (publicKeyObject: any) {
16} 21}
17 22
18function isActorTypeValid (type: string) { 23function 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
22function isActorPublicKeyValid (publicKey: string) { 27function isActorPublicKeyValid (publicKey: string) {
@@ -81,9 +86,11 @@ function sanitizeAndCheckActorObject (object: any) {
81} 86}
82 87
83function normalizeActor (actor: any) { 88function 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