diff options
Diffstat (limited to 'server/lib/activitypub/send/send-like.ts')
-rw-r--r-- | server/lib/activitypub/send/send-like.ts | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/server/lib/activitypub/send/send-like.ts b/server/lib/activitypub/send/send-like.ts index 41b879b8a..0c464b2d3 100644 --- a/server/lib/activitypub/send/send-like.ts +++ b/server/lib/activitypub/send/send-like.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import { Transaction } from 'sequelize' | 1 | import { Transaction } from 'sequelize' |
2 | import { ActivityLike } from '../../../../shared/models/activitypub/activity' | 2 | import { ActivityAudience, ActivityLike } from '../../../../shared/models/activitypub/activity' |
3 | import { AccountInstance, VideoInstance } from '../../../models' | 3 | import { AccountInstance, VideoInstance } from '../../../models' |
4 | import { getVideoLikeActivityPubUrl } from '../url' | 4 | import { getVideoLikeActivityPubUrl } from '../url' |
5 | import { | 5 | import { |
@@ -14,9 +14,9 @@ import { | |||
14 | async function sendLikeToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { | 14 | async function sendLikeToOrigin (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { |
15 | const url = getVideoLikeActivityPubUrl(byAccount, video) | 15 | const url = getVideoLikeActivityPubUrl(byAccount, video) |
16 | 16 | ||
17 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video) | 17 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t) |
18 | const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) | 18 | const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) |
19 | const data = await likeActivityData(url, byAccount, video, audience) | 19 | const data = await likeActivityData(url, byAccount, video, t, audience) |
20 | 20 | ||
21 | return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) | 21 | return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) |
22 | } | 22 | } |
@@ -24,19 +24,23 @@ async function sendLikeToOrigin (byAccount: AccountInstance, video: VideoInstanc | |||
24 | async function sendLikeToVideoFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { | 24 | async function sendLikeToVideoFollowers (byAccount: AccountInstance, video: VideoInstance, t: Transaction) { |
25 | const url = getVideoLikeActivityPubUrl(byAccount, video) | 25 | const url = getVideoLikeActivityPubUrl(byAccount, video) |
26 | 26 | ||
27 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video) | 27 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t) |
28 | const audience = getObjectFollowersAudience(accountsInvolvedInVideo) | 28 | const audience = getObjectFollowersAudience(accountsInvolvedInVideo) |
29 | const data = await likeActivityData(url, byAccount, video, audience) | 29 | const data = await likeActivityData(url, byAccount, video, t, audience) |
30 | |||
31 | const toAccountsFollowers = await getAccountsInvolvedInVideo(video) | ||
32 | 30 | ||
33 | const followersException = [ byAccount ] | 31 | const followersException = [ byAccount ] |
34 | return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException) | 32 | return broadcastToFollowers(data, byAccount, accountsInvolvedInVideo, t, followersException) |
35 | } | 33 | } |
36 | 34 | ||
37 | async function likeActivityData (url: string, byAccount: AccountInstance, video: VideoInstance, audience?: { to: string[], cc: string[] }) { | 35 | async function likeActivityData ( |
36 | url: string, | ||
37 | byAccount: AccountInstance, | ||
38 | video: VideoInstance, | ||
39 | t: Transaction, | ||
40 | audience?: ActivityAudience | ||
41 | ) { | ||
38 | if (!audience) { | 42 | if (!audience) { |
39 | audience = await getAudience(byAccount) | 43 | audience = await getAudience(byAccount, t) |
40 | } | 44 | } |
41 | 45 | ||
42 | const activity: ActivityLike = { | 46 | const activity: ActivityLike = { |