1 import { Transaction } from 'sequelize'
2 import { ActivityLike } from '../../../../shared/models/activitypub/activity'
3 import { getServerAccount } from '../../../helpers/utils'
4 import { AccountInstance, VideoInstance } from '../../../models'
5 import { getVideoLikeActivityPubUrl } from '../url'
8 getAccountsToForwardVideoAction,
10 getOriginVideoAudience,
11 getVideoFollowersAudience,
15 async function sendLikeToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) {
16 const url = getVideoLikeActivityPubUrl(byAccount, video)
18 const audience = getOriginVideoAudience(video)
19 const data = await likeActivityData(url, byAccount, video, 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 audience = getVideoFollowersAudience(video)
28 const data = await likeActivityData(url, byAccount, video, audience)
30 const accountsToForwardView = await getAccountsToForwardVideoAction(byAccount, video)
31 const serverAccount = await getServerAccount()
33 const followersException = [ byAccount ]
34 return broadcastToFollowers(data, serverAccount, accountsToForwardView, t, followersException)
37 async function likeActivityData (url: string, byAccount: AccountInstance, video: VideoInstance, audience?: { to: string[], cc: string[] }) {
39 audience = await getAudience(byAccount)
42 const activity: ActivityLike = {
54 // ---------------------------------------------------------------------------
58 sendLikeToVideoFollowers,