]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix actor outbox
authorChocobozzz <me@florianbigard.com>
Mon, 28 May 2018 10:13:00 +0000 (12:13 +0200)
committerChocobozzz <me@florianbigard.com>
Mon, 28 May 2018 10:13:00 +0000 (12:13 +0200)
server/controllers/activitypub/outbox.ts
server/lib/activitypub/audience.ts
server/models/video/video.ts

index 97bf9b052d7ec82f3c9aa2bfccae23a2591e8345..2793ae2677739961f461458e2253e9504d9be0dd 100644 (file)
@@ -47,17 +47,14 @@ async function buildActivities (actor: ActorModel, start: number, count: number)
   const actors = data.data.map(v => v.VideoChannel.Account.Actor)
   actors.push(actor)
 
-  const followersMatrix = await ActorModel.getActorsFollowerSharedInboxUrls(actors, undefined)
-
   for (const video of data.data) {
     const byActor = video.VideoChannel.Account.Actor
-    const createActivityAudience = buildAudience(followersMatrix[byActor.id], video.privacy === VideoPrivacy.PUBLIC)
+    const createActivityAudience = buildAudience([ byActor.followersUrl ], video.privacy === VideoPrivacy.PUBLIC)
 
     // This is a shared video
     if (video.VideoShares !== undefined && video.VideoShares.length !== 0) {
       const videoShare = video.VideoShares[0]
-      const announceAudience = buildAudience(followersMatrix[actor.id], video.privacy === VideoPrivacy.PUBLIC)
-      const announceActivity = await announceActivityData(videoShare.url, actor, video.url, undefined, announceAudience)
+      const announceActivity = await announceActivityData(videoShare.url, actor, video.url, undefined, createActivityAudience)
 
       activities.push(announceActivity)
     } else {
index 916358fe2c607978ef9bd8ea7382d2a7db2a16dd..c1265dbcd3314435cd68f53e2c3cce8bc63d447d 100644 (file)
@@ -59,14 +59,13 @@ async function getAudience (actorSender: ActorModel, t: Transaction, isPublic =
   return buildAudience([ actorSender.followersUrl ], isPublic)
 }
 
-function buildAudience (followerInboxUrls: string[], isPublic = true) {
-  // Thanks Mastodon: https://github.com/tootsuite/mastodon/blob/master/app/lib/activitypub/tag_manager.rb#L47
+function buildAudience (followerUrls: string[], isPublic = true) {
   let to = []
   let cc = []
 
   if (isPublic) {
     to = [ ACTIVITY_PUB.PUBLIC ]
-    cc = followerInboxUrls
+    cc = followerUrls
   } else { // Unlisted
     to = [ ]
     cc = [ ]
index f4689fe129f68954d1cb98aa84cf905b21447ef0..1640cd57f2a643ffcb92384b1429ad29c9e01959 100644 (file)
@@ -602,6 +602,19 @@ export class VideoModel extends Model<VideoModel> {
           attributes: [ 'id', 'url' ],
           model: VideoShareModel.unscoped(),
           required: false,
+          // We only want videos shared by this actor
+          where: {
+            [Sequelize.Op.and]: [
+              {
+                id: {
+                  [Sequelize.Op.not]: null
+                }
+              },
+              {
+                actorId
+              }
+            ]
+          },
           include: [
             {
               attributes: [ 'id', 'url' ],
@@ -619,14 +632,14 @@ export class VideoModel extends Model<VideoModel> {
               required: true,
               include: [
                 {
-                  attributes: [ 'id', 'url' ],
+                  attributes: [ 'id', 'url', 'followersUrl' ],
                   model: ActorModel.unscoped(),
                   required: true
                 }
               ]
             },
             {
-              attributes: [ 'id', 'url' ],
+              attributes: [ 'id', 'url', 'followersUrl' ],
               model: ActorModel.unscoped(),
               required: true
             }