]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/send/send-like.ts
Fix cc field in classic audience
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-like.ts
index 743646455e7d751b564f44cdaf3e27ac977188e4..fb2b4aaf87132f356af319c6930a4887b2da0cf3 100644 (file)
@@ -13,20 +13,20 @@ import {
   unicastTo
 } from './misc'
 
-async function sendLikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) {
+async function sendLike (byActor: ActorModel, video: VideoModel, t: Transaction) {
   const url = getVideoLikeActivityPubUrl(byActor, video)
 
   const accountsInvolvedInVideo = await getActorsInvolvedInVideo(video, t)
-  const audience = getOriginVideoAudience(video, accountsInvolvedInVideo)
-  const data = await likeActivityData(url, byActor, video, t, audience)
 
-  return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl, t)
-}
+  // Send to origin
+  if (video.isOwned() === false) {
+    const audience = getOriginVideoAudience(video, accountsInvolvedInVideo)
+    const data = await likeActivityData(url, byActor, video, t, audience)
 
-async function sendLikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) {
-  const url = getVideoLikeActivityPubUrl(byActor, video)
+    return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl)
+  }
 
-  const accountsInvolvedInVideo = await getActorsInvolvedInVideo(video, t)
+  // Send to followers
   const audience = getObjectFollowersAudience(accountsInvolvedInVideo)
   const data = await likeActivityData(url, byActor, video, t, audience)
 
@@ -46,7 +46,7 @@ async function likeActivityData (
   }
 
   return audiencify({
-    type: 'Like',
+    type: 'Like' as 'Like',
     id: url,
     actor: byActor.url,
     object: video.url
@@ -56,7 +56,6 @@ async function likeActivityData (
 // ---------------------------------------------------------------------------
 
 export {
-  sendLikeToOrigin,
-  sendLikeToVideoFollowers,
+  sendLike,
   likeActivityData
 }