aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/activitypub
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-10-23 11:33:53 +0200
committerChocobozzz <me@florianbigard.com>2019-10-23 11:33:53 +0200
commit47581df0737ebcc058a5863143c752f9112a4424 (patch)
tree3b64e3fc49de4bea41d8fd852201ba3abb6b4994 /server/models/activitypub
parenta0e6d267598839c8a5508a65876ce0e07d1b3d74 (diff)
downloadPeerTube-47581df0737ebcc058a5863143c752f9112a4424.tar.gz
PeerTube-47581df0737ebcc058a5863143c752f9112a4424.tar.zst
PeerTube-47581df0737ebcc058a5863143c752f9112a4424.zip
Fix federation with some actors
That don't have a shared inbox, or a URL
Diffstat (limited to 'server/models/activitypub')
-rw-r--r--server/models/activitypub/actor-follow.ts8
-rw-r--r--server/models/activitypub/actor.ts11
2 files changed, 12 insertions, 7 deletions
diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts
index 8498692f0..fb3c4ef9d 100644
--- a/server/models/activitypub/actor-follow.ts
+++ b/server/models/activitypub/actor-follow.ts
@@ -574,8 +574,8 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
574 } 574 }
575 575
576 const selections: string[] = [] 576 const selections: string[] = []
577 if (distinct === true) selections.push('DISTINCT("Follows"."' + columnUrl + '") AS "url"') 577 if (distinct === true) selections.push('DISTINCT("Follows"."' + columnUrl + '") AS "selectionUrl"')
578 else selections.push('"Follows"."' + columnUrl + '" AS "url"') 578 else selections.push('"Follows"."' + columnUrl + '" AS "selectionUrl"')
579 579
580 selections.push('COUNT(*) AS "total"') 580 selections.push('COUNT(*) AS "total"')
581 581
@@ -585,7 +585,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
585 let query = 'SELECT ' + selection + ' FROM "actor" ' + 585 let query = 'SELECT ' + selection + ' FROM "actor" ' +
586 'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' + 586 'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' +
587 'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' + 587 'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' +
588 'WHERE "actor"."id" = ANY ($actorIds) AND "actorFollow"."state" = \'accepted\' ' 588 'WHERE "actor"."id" = ANY ($actorIds) AND "actorFollow"."state" = \'accepted\' AND "selectionUrl" IS NOT NULL '
589 589
590 if (count !== undefined) query += 'LIMIT ' + count 590 if (count !== undefined) query += 'LIMIT ' + count
591 if (start !== undefined) query += ' OFFSET ' + start 591 if (start !== undefined) query += ' OFFSET ' + start
@@ -599,7 +599,7 @@ export class ActorFollowModel extends Model<ActorFollowModel> {
599 } 599 }
600 600
601 const [ followers, [ dataTotal ] ] = await Promise.all(tasks) 601 const [ followers, [ dataTotal ] ] = await Promise.all(tasks)
602 const urls: string[] = followers.map(f => f.url) 602 const urls: string[] = followers.map(f => f.selectionUrl)
603 603
604 return { 604 return {
605 data: urls, 605 data: urls,
diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts
index 535ebd792..42a24b583 100644
--- a/server/models/activitypub/actor.ts
+++ b/server/models/activitypub/actor.ts
@@ -44,7 +44,8 @@ import {
44 MActorFull, 44 MActorFull,
45 MActorHost, 45 MActorHost,
46 MActorServer, 46 MActorServer,
47 MActorSummaryFormattable 47 MActorSummaryFormattable,
48 MActorWithInboxes
48} from '../../typings/models' 49} from '../../typings/models'
49import * as Bluebird from 'bluebird' 50import * as Bluebird from 'bluebird'
50 51
@@ -179,8 +180,8 @@ export class ActorModel extends Model<ActorModel> {
179 @Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max)) 180 @Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
180 outboxUrl: string 181 outboxUrl: string
181 182
182 @AllowNull(false) 183 @AllowNull(true)
183 @Is('ActorSharedInboxUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'shared inbox url')) 184 @Is('ActorSharedInboxUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'shared inbox url', true))
184 @Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max)) 185 @Column(DataType.STRING(CONSTRAINTS_FIELDS.ACTORS.URL.max))
185 sharedInboxUrl: string 186 sharedInboxUrl: string
186 187
@@ -402,6 +403,10 @@ export class ActorModel extends Model<ActorModel> {
402 }) 403 })
403 } 404 }
404 405
406 getSharedInbox (this: MActorWithInboxes) {
407 return this.sharedInboxUrl || this.inboxUrl
408 }
409
405 toFormattedSummaryJSON (this: MActorSummaryFormattable) { 410 toFormattedSummaryJSON (this: MActorSummaryFormattable) {
406 let avatar: Avatar = null 411 let avatar: Avatar = null
407 if (this.Avatar) { 412 if (this.Avatar) {