aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-03-22 18:40:33 +0100
committerChocobozzz <me@florianbigard.com>2018-03-22 18:40:56 +0100
commit6be84cbcea99518e8eca58c76259effd0dd992fd (patch)
treec2b4b22c8b60528025b172013d72c12f8ba06192 /server/helpers
parent9e841674da612b68bf84a427a8710a44347083f5 (diff)
downloadPeerTube-6be84cbcea99518e8eca58c76259effd0dd992fd.tar.gz
PeerTube-6be84cbcea99518e8eca58c76259effd0dd992fd.tar.zst
PeerTube-6be84cbcea99518e8eca58c76259effd0dd992fd.zip
Improve activity pub actors implementation
Diffstat (limited to 'server/helpers')
-rw-r--r--server/helpers/activitypub.ts9
-rw-r--r--server/helpers/custom-validators/activitypub/activity.ts2
-rw-r--r--server/helpers/custom-validators/activitypub/misc.ts2
3 files changed, 10 insertions, 3 deletions
diff --git a/server/helpers/activitypub.ts b/server/helpers/activitypub.ts
index d64a6dd78..1934fa0f0 100644
--- a/server/helpers/activitypub.ts
+++ b/server/helpers/activitypub.ts
@@ -1,5 +1,5 @@
1import { ResultList } from '../../shared/models' 1import { ResultList } from '../../shared/models'
2import { Activity } from '../../shared/models/activitypub' 2import { Activity, ActivityPubActor } from '../../shared/models/activitypub'
3import { ACTIVITY_PUB } from '../initializers' 3import { ACTIVITY_PUB } from '../initializers'
4import { ActorModel } from '../models/activitypub/actor' 4import { ActorModel } from '../models/activitypub/actor'
5import { signObject } from './peertube-crypto' 5import { signObject } from './peertube-crypto'
@@ -98,9 +98,16 @@ function buildSignedActivity (byActor: ActorModel, data: Object) {
98 return signObject(byActor, activity) as Promise<Activity> 98 return signObject(byActor, activity) as Promise<Activity>
99} 99}
100 100
101function getActorUrl (activityActor: string | ActivityPubActor) {
102 if (typeof activityActor === 'string') return activityActor
103
104 return activityActor.id
105}
106
101// --------------------------------------------------------------------------- 107// ---------------------------------------------------------------------------
102 108
103export { 109export {
110 getActorUrl,
104 activityPubContextify, 111 activityPubContextify,
105 activityPubCollectionPagination, 112 activityPubCollectionPagination,
106 activityPubCollection, 113 activityPubCollection,
diff --git a/server/helpers/custom-validators/activitypub/activity.ts b/server/helpers/custom-validators/activitypub/activity.ts
index 632f14223..7e4dccefb 100644
--- a/server/helpers/custom-validators/activitypub/activity.ts
+++ b/server/helpers/custom-validators/activitypub/activity.ts
@@ -26,7 +26,7 @@ function isRootActivityValid (activity: any) {
26 ) || 26 ) ||
27 ( 27 (
28 isActivityPubUrlValid(activity.id) && 28 isActivityPubUrlValid(activity.id) &&
29 isActivityPubUrlValid(activity.actor) 29 (isActivityPubUrlValid(activity.actor) || isActivityPubUrlValid(activity.actor.id))
30 ) 30 )
31} 31}
32 32
diff --git a/server/helpers/custom-validators/activitypub/misc.ts b/server/helpers/custom-validators/activitypub/misc.ts
index 75d308e9d..2dac8e1ad 100644
--- a/server/helpers/custom-validators/activitypub/misc.ts
+++ b/server/helpers/custom-validators/activitypub/misc.ts
@@ -24,7 +24,7 @@ function isBaseActivityValid (activity: any, type: string) {
24 return (activity['@context'] === undefined || Array.isArray(activity['@context'])) && 24 return (activity['@context'] === undefined || Array.isArray(activity['@context'])) &&
25 activity.type === type && 25 activity.type === type &&
26 isActivityPubUrlValid(activity.id) && 26 isActivityPubUrlValid(activity.id) &&
27 isActivityPubUrlValid(activity.actor) && 27 (isActivityPubUrlValid(activity.actor) || isActivityPubUrlValid(activity.actor.id)) &&
28 ( 28 (
29 activity.to === undefined || 29 activity.to === undefined ||
30 (Array.isArray(activity.to) && activity.to.every(t => isActivityPubUrlValid(t))) 30 (Array.isArray(activity.to) && activity.to.every(t => isActivityPubUrlValid(t)))