]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/send/send-like.ts
Add concept of video state, and add ability to wait transcoding before
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-like.ts
index ddeb1fcd2e375bdc05fea4ebdaed0c6a3a3551cb..37ee7c09669951506d0f1c5c883fe3c731db4ca6 100644 (file)
@@ -14,36 +14,31 @@ async function sendLike (byActor: ActorModel, video: VideoModel, t: Transaction)
   // Send to origin
   if (video.isOwned() === false) {
     const audience = getVideoAudience(video, accountsInvolvedInVideo)
-    const data = await likeActivityData(url, byActor, video, t, audience)
+    const data = likeActivityData(url, byActor, video, audience)
 
     return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
   }
 
   // Send to followers
   const audience = getObjectFollowersAudience(accountsInvolvedInVideo)
-  const data = await likeActivityData(url, byActor, video, t, audience)
+  const data = likeActivityData(url, byActor, video, audience)
 
   const followersException = [ byActor ]
   return broadcastToFollowers(data, byActor, accountsInvolvedInVideo, t, followersException)
 }
 
-async function likeActivityData (
-  url: string,
-  byActor: ActorModel,
-  video: VideoModel,
-  t: Transaction,
-  audience?: ActivityAudience
-): Promise<ActivityLike> {
-  if (!audience) {
-    audience = await getAudience(byActor, t)
-  }
-
-  return audiencify({
-    type: 'Like' as 'Like',
-    id: url,
-    actor: byActor.url,
-    object: video.url
-  }, audience)
+function likeActivityData (url: string, byActor: ActorModel, video: VideoModel, audience?: ActivityAudience): ActivityLike {
+  if (!audience) audience = getAudience(byActor)
+
+  return audiencify(
+    {
+      type: 'Like' as 'Like',
+      id: url,
+      actor: byActor.url,
+      object: video.url
+    },
+    audience
+  )
 }
 
 // ---------------------------------------------------------------------------