aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/activitypub/outbox.ts7
-rw-r--r--server/lib/activitypub/audience.ts5
-rw-r--r--server/models/video/video.ts17
3 files changed, 19 insertions, 10 deletions
diff --git a/server/controllers/activitypub/outbox.ts b/server/controllers/activitypub/outbox.ts
index 97bf9b052..2793ae267 100644
--- a/server/controllers/activitypub/outbox.ts
+++ b/server/controllers/activitypub/outbox.ts
@@ -47,17 +47,14 @@ async function buildActivities (actor: ActorModel, start: number, count: number)
47 const actors = data.data.map(v => v.VideoChannel.Account.Actor) 47 const actors = data.data.map(v => v.VideoChannel.Account.Actor)
48 actors.push(actor) 48 actors.push(actor)
49 49
50 const followersMatrix = await ActorModel.getActorsFollowerSharedInboxUrls(actors, undefined)
51
52 for (const video of data.data) { 50 for (const video of data.data) {
53 const byActor = video.VideoChannel.Account.Actor 51 const byActor = video.VideoChannel.Account.Actor
54 const createActivityAudience = buildAudience(followersMatrix[byActor.id], video.privacy === VideoPrivacy.PUBLIC) 52 const createActivityAudience = buildAudience([ byActor.followersUrl ], video.privacy === VideoPrivacy.PUBLIC)
55 53
56 // This is a shared video 54 // This is a shared video
57 if (video.VideoShares !== undefined && video.VideoShares.length !== 0) { 55 if (video.VideoShares !== undefined && video.VideoShares.length !== 0) {
58 const videoShare = video.VideoShares[0] 56 const videoShare = video.VideoShares[0]
59 const announceAudience = buildAudience(followersMatrix[actor.id], video.privacy === VideoPrivacy.PUBLIC) 57 const announceActivity = await announceActivityData(videoShare.url, actor, video.url, undefined, createActivityAudience)
60 const announceActivity = await announceActivityData(videoShare.url, actor, video.url, undefined, announceAudience)
61 58
62 activities.push(announceActivity) 59 activities.push(announceActivity)
63 } else { 60 } else {
diff --git a/server/lib/activitypub/audience.ts b/server/lib/activitypub/audience.ts
index 916358fe2..c1265dbcd 100644
--- a/server/lib/activitypub/audience.ts
+++ b/server/lib/activitypub/audience.ts
@@ -59,14 +59,13 @@ async function getAudience (actorSender: ActorModel, t: Transaction, isPublic =
59 return buildAudience([ actorSender.followersUrl ], isPublic) 59 return buildAudience([ actorSender.followersUrl ], isPublic)
60} 60}
61 61
62function buildAudience (followerInboxUrls: string[], isPublic = true) { 62function buildAudience (followerUrls: string[], isPublic = true) {
63 // Thanks Mastodon: https://github.com/tootsuite/mastodon/blob/master/app/lib/activitypub/tag_manager.rb#L47
64 let to = [] 63 let to = []
65 let cc = [] 64 let cc = []
66 65
67 if (isPublic) { 66 if (isPublic) {
68 to = [ ACTIVITY_PUB.PUBLIC ] 67 to = [ ACTIVITY_PUB.PUBLIC ]
69 cc = followerInboxUrls 68 cc = followerUrls
70 } else { // Unlisted 69 } else { // Unlisted
71 to = [ ] 70 to = [ ]
72 cc = [ ] 71 cc = [ ]
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index f4689fe12..1640cd57f 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -602,6 +602,19 @@ export class VideoModel extends Model<VideoModel> {
602 attributes: [ 'id', 'url' ], 602 attributes: [ 'id', 'url' ],
603 model: VideoShareModel.unscoped(), 603 model: VideoShareModel.unscoped(),
604 required: false, 604 required: false,
605 // We only want videos shared by this actor
606 where: {
607 [Sequelize.Op.and]: [
608 {
609 id: {
610 [Sequelize.Op.not]: null
611 }
612 },
613 {
614 actorId
615 }
616 ]
617 },
605 include: [ 618 include: [
606 { 619 {
607 attributes: [ 'id', 'url' ], 620 attributes: [ 'id', 'url' ],
@@ -619,14 +632,14 @@ export class VideoModel extends Model<VideoModel> {
619 required: true, 632 required: true,
620 include: [ 633 include: [
621 { 634 {
622 attributes: [ 'id', 'url' ], 635 attributes: [ 'id', 'url', 'followersUrl' ],
623 model: ActorModel.unscoped(), 636 model: ActorModel.unscoped(),
624 required: true 637 required: true
625 } 638 }
626 ] 639 ]
627 }, 640 },
628 { 641 {
629 attributes: [ 'id', 'url' ], 642 attributes: [ 'id', 'url', 'followersUrl' ],
630 model: ActorModel.unscoped(), 643 model: ActorModel.unscoped(),
631 required: true 644 required: true
632 } 645 }