diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-30 11:31:15 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-30 11:31:15 +0100 |
commit | 25ed141c7c7631ef21d8764c1163fbf8a6591391 (patch) | |
tree | 8f556181a3369e7e4938d612d91be0af813e5067 /server/lib/activitypub/send/send-announce.ts | |
parent | 5cd80545422bba855cc9a730a2e13cc9d982c34b (diff) | |
download | PeerTube-25ed141c7c7631ef21d8764c1163fbf8a6591391.tar.gz PeerTube-25ed141c7c7631ef21d8764c1163fbf8a6591391.tar.zst PeerTube-25ed141c7c7631ef21d8764c1163fbf8a6591391.zip |
Put activity pub sends inside transactions
Diffstat (limited to 'server/lib/activitypub/send/send-announce.ts')
-rw-r--r-- | server/lib/activitypub/send/send-announce.ts | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/server/lib/activitypub/send/send-announce.ts b/server/lib/activitypub/send/send-announce.ts index efc23af46..3acf604cd 100644 --- a/server/lib/activitypub/send/send-announce.ts +++ b/server/lib/activitypub/send/send-announce.ts | |||
@@ -21,11 +21,11 @@ async function buildVideoAnnounceToFollowers (byAccount: AccountInstance, video: | |||
21 | const url = getAnnounceActivityPubUrl(video.url, byAccount) | 21 | const url = getAnnounceActivityPubUrl(video.url, byAccount) |
22 | 22 | ||
23 | const videoChannel = video.VideoChannel | 23 | const videoChannel = video.VideoChannel |
24 | const announcedActivity = await addActivityData(url, videoChannel.Account, video, videoChannel.url, video.toActivityPubObject()) | 24 | const announcedActivity = await addActivityData(url, videoChannel.Account, video, videoChannel.url, video.toActivityPubObject(), t) |
25 | 25 | ||
26 | const accountsToForwardView = await getAccountsInvolvedInVideo(video) | 26 | const accountsToForwardView = await getAccountsInvolvedInVideo(video, t) |
27 | const audience = getObjectFollowersAudience(accountsToForwardView) | 27 | const audience = getObjectFollowersAudience(accountsToForwardView) |
28 | const data = await announceActivityData(url, byAccount, announcedActivity, audience) | 28 | const data = await announceActivityData(url, byAccount, announcedActivity, t, audience) |
29 | 29 | ||
30 | return data | 30 | return data |
31 | } | 31 | } |
@@ -40,22 +40,22 @@ async function sendVideoAnnounceToOrigin (byAccount: AccountInstance, video: Vid | |||
40 | const url = getAnnounceActivityPubUrl(video.url, byAccount) | 40 | const url = getAnnounceActivityPubUrl(video.url, byAccount) |
41 | 41 | ||
42 | const videoChannel = video.VideoChannel | 42 | const videoChannel = video.VideoChannel |
43 | const announcedActivity = await addActivityData(url, videoChannel.Account, video, videoChannel.url, video.toActivityPubObject()) | 43 | const announcedActivity = await addActivityData(url, videoChannel.Account, video, videoChannel.url, video.toActivityPubObject(), t) |
44 | 44 | ||
45 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video) | 45 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t) |
46 | const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) | 46 | const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) |
47 | const data = await createActivityData(url, byAccount, announcedActivity, audience) | 47 | const data = await createActivityData(url, byAccount, announcedActivity, t, audience) |
48 | 48 | ||
49 | return unicastTo(data, byAccount, videoChannel.Account.sharedInboxUrl, t) | 49 | return unicastTo(data, byAccount, videoChannel.Account.sharedInboxUrl, t) |
50 | } | 50 | } |
51 | 51 | ||
52 | async function buildVideoChannelAnnounceToFollowers (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { | 52 | async function buildVideoChannelAnnounceToFollowers (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { |
53 | const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) | 53 | const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) |
54 | const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject()) | 54 | const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject(), t) |
55 | 55 | ||
56 | const accountsToForwardView = await getAccountsInvolvedInVideoChannel(videoChannel) | 56 | const accountsToForwardView = await getAccountsInvolvedInVideoChannel(videoChannel, t) |
57 | const audience = getObjectFollowersAudience(accountsToForwardView) | 57 | const audience = getObjectFollowersAudience(accountsToForwardView) |
58 | const data = await announceActivityData(url, byAccount, announcedActivity, audience) | 58 | const data = await announceActivityData(url, byAccount, announcedActivity, t, audience) |
59 | 59 | ||
60 | return data | 60 | return data |
61 | } | 61 | } |
@@ -68,11 +68,11 @@ async function sendVideoChannelAnnounceToFollowers (byAccount: AccountInstance, | |||
68 | 68 | ||
69 | async function sendVideoChannelAnnounceToOrigin (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { | 69 | async function sendVideoChannelAnnounceToOrigin (byAccount: AccountInstance, videoChannel: VideoChannelInstance, t: Transaction) { |
70 | const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) | 70 | const url = getAnnounceActivityPubUrl(videoChannel.url, byAccount) |
71 | const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject()) | 71 | const announcedActivity = await createActivityData(url, videoChannel.Account, videoChannel.toActivityPubObject(), t) |
72 | 72 | ||
73 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideoChannel(videoChannel) | 73 | const accountsInvolvedInVideo = await getAccountsInvolvedInVideoChannel(videoChannel, t) |
74 | const audience = getOriginVideoChannelAudience(videoChannel, accountsInvolvedInVideo) | 74 | const audience = getOriginVideoChannelAudience(videoChannel, accountsInvolvedInVideo) |
75 | const data = await createActivityData(url, byAccount, announcedActivity, audience) | 75 | const data = await createActivityData(url, byAccount, announcedActivity, t, audience) |
76 | 76 | ||
77 | return unicastTo(data, byAccount, videoChannel.Account.sharedInboxUrl, t) | 77 | return unicastTo(data, byAccount, videoChannel.Account.sharedInboxUrl, t) |
78 | } | 78 | } |
@@ -81,10 +81,11 @@ async function announceActivityData ( | |||
81 | url: string, | 81 | url: string, |
82 | byAccount: AccountInstance, | 82 | byAccount: AccountInstance, |
83 | object: ActivityCreate | ActivityAdd, | 83 | object: ActivityCreate | ActivityAdd, |
84 | t: Transaction, | ||
84 | audience?: ActivityAudience | 85 | audience?: ActivityAudience |
85 | ) { | 86 | ) { |
86 | if (!audience) { | 87 | if (!audience) { |
87 | audience = await getAudience(byAccount) | 88 | audience = await getAudience(byAccount, t) |
88 | } | 89 | } |
89 | 90 | ||
90 | const activity: ActivityAnnounce = { | 91 | const activity: ActivityAnnounce = { |