1 import { Transaction } from 'sequelize'
2 import { ActivityAudience, ActivityLike } from '../../../../shared/models/activitypub'
3 import { AccountModel } from '../../../models/account/account'
4 import { VideoModel } from '../../../models/video/video'
5 import { getVideoLikeActivityPubUrl } from '../url'
8 getAccountsInvolvedInVideo,
10 getOriginVideoAudience,
11 getObjectFollowersAudience,
15 async function sendLikeToOrigin (byAccount: AccountModel, video: VideoModel, t: Transaction) {
16 const url = getVideoLikeActivityPubUrl(byAccount, video)
18 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t)
19 const audience = getOriginVideoAudience(video, accountsInvolvedInVideo)
20 const data = await likeActivityData(url, byAccount, video, t, audience)
22 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
25 async function sendLikeToVideoFollowers (byAccount: AccountModel, video: VideoModel, t: Transaction) {
26 const url = getVideoLikeActivityPubUrl(byAccount, video)
28 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t)
29 const audience = getObjectFollowersAudience(accountsInvolvedInVideo)
30 const data = await likeActivityData(url, byAccount, video, t, audience)
32 const followersException = [ byAccount ]
33 return broadcastToFollowers(data, byAccount, accountsInvolvedInVideo, t, followersException)
36 async function likeActivityData (
38 byAccount: AccountModel,
41 audience?: ActivityAudience
42 ): Promise<ActivityLike> {
44 audience = await getAudience(byAccount, t)
57 // ---------------------------------------------------------------------------
61 sendLikeToVideoFollowers,