1 import { Transaction } from 'sequelize'
2 import { ActivityAudience, ActivityLike } from '../../../../shared/models/activitypub/activity'
3 import { AccountInstance, VideoInstance } from '../../../models'
4 import { getVideoLikeActivityPubUrl } from '../url'
7 getAccountsInvolvedInVideo,
9 getOriginVideoAudience,
10 getObjectFollowersAudience,
14 async function sendLikeToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) {
15 const url = getVideoLikeActivityPubUrl(byAccount, video)
17 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t)
18 const audience = getOriginVideoAudience(video, accountsInvolvedInVideo)
19 const data = await likeActivityData(url, byAccount, video, t, audience)
21 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
24 async function sendLikeToVideoFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) {
25 const url = getVideoLikeActivityPubUrl(byAccount, video)
27 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t)
28 const audience = getObjectFollowersAudience(accountsInvolvedInVideo)
29 const data = await likeActivityData(url, byAccount, video, t, audience)
31 const followersException = [ byAccount ]
32 return broadcastToFollowers(data, byAccount, accountsInvolvedInVideo, t, followersException)
35 async function likeActivityData (
37 byAccount: AccountInstance,
40 audience?: ActivityAudience
43 audience = await getAudience(byAccount, t)
46 const activity: ActivityLike = {
58 // ---------------------------------------------------------------------------
62 sendLikeToVideoFollowers,