diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-16 15:25:20 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 06a05d5f4784a7cbb27aa1188385b5679845dad8 (patch) | |
tree | ac197f3ed0768529456225ad76c912f22bc55e29 /server/helpers/custom-validators/activitypub/actor.ts | |
parent | 4bda2e47bbc937c401ddcf14c1be53c70481a294 (diff) | |
download | PeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.tar.gz PeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.tar.zst PeerTube-06a05d5f4784a7cbb27aa1188385b5679845dad8.zip |
Add subscriptions endpoints to REST API
Diffstat (limited to 'server/helpers/custom-validators/activitypub/actor.ts')
-rw-r--r-- | server/helpers/custom-validators/activitypub/actor.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts index c7a64e24d..ae5014f8f 100644 --- a/server/helpers/custom-validators/activitypub/actor.ts +++ b/server/helpers/custom-validators/activitypub/actor.ts | |||
@@ -3,6 +3,7 @@ import { CONSTRAINTS_FIELDS } from '../../../initializers' | |||
3 | import { exists } from '../misc' | 3 | import { exists } from '../misc' |
4 | import { truncate } from 'lodash' | 4 | import { truncate } from 'lodash' |
5 | import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc' | 5 | import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc' |
6 | import { isHostValid } from '../servers' | ||
6 | 7 | ||
7 | function isActorEndpointsObjectValid (endpointObject: any) { | 8 | function isActorEndpointsObjectValid (endpointObject: any) { |
8 | return isActivityPubUrlValid(endpointObject.sharedInbox) | 9 | return isActivityPubUrlValid(endpointObject.sharedInbox) |
@@ -109,6 +110,15 @@ function normalizeActor (actor: any) { | |||
109 | return | 110 | return |
110 | } | 111 | } |
111 | 112 | ||
113 | function isValidActorHandle (handle: string) { | ||
114 | if (!exists(handle)) return false | ||
115 | |||
116 | const parts = handle.split('@') | ||
117 | if (parts.length !== 2) return false | ||
118 | |||
119 | return isHostValid(parts[1]) | ||
120 | } | ||
121 | |||
112 | // --------------------------------------------------------------------------- | 122 | // --------------------------------------------------------------------------- |
113 | 123 | ||
114 | export { | 124 | export { |
@@ -126,5 +136,6 @@ export { | |||
126 | isActorAcceptActivityValid, | 136 | isActorAcceptActivityValid, |
127 | isActorRejectActivityValid, | 137 | isActorRejectActivityValid, |
128 | isActorDeleteActivityValid, | 138 | isActorDeleteActivityValid, |
129 | isActorUpdateActivityValid | 139 | isActorUpdateActivityValid, |
140 | isValidActorHandle | ||
130 | } | 141 | } |