]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/send/send-update.ts
Put activity pub sends inside transactions
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / send / send-update.ts
index 32cada06e3fb691a112dfc1ce46bcee74e6c999e..59524e523738b636dc36d0eae3f46f5e570f5e94 100644 (file)
@@ -10,9 +10,9 @@ async function sendUpdateVideoChannel (videoChannel: VideoChannelInstance, t: Tr
 
   const url = getUpdateActivityPubUrl(videoChannel.url, videoChannel.updatedAt.toISOString())
   const videoChannelObject = videoChannel.toActivityPubObject()
-  const data = await updateActivityData(url, byAccount, videoChannelObject)
+  const data = await updateActivityData(url, byAccount, videoChannelObject, t)
 
-  const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id)
+  const accountsInvolved = await db.VideoChannelShare.loadAccountsByShare(videoChannel.id, t)
   accountsInvolved.push(byAccount)
 
   return broadcastToFollowers(data, byAccount, accountsInvolved, t)
@@ -23,9 +23,9 @@ async function sendUpdateVideo (video: VideoInstance, t: Transaction) {
 
   const url = getUpdateActivityPubUrl(video.url, video.updatedAt.toISOString())
   const videoObject = video.toActivityPubObject()
-  const data = await updateActivityData(url, byAccount, videoObject)
+  const data = await updateActivityData(url, byAccount, videoObject, t)
 
-  const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id)
+  const accountsInvolved = await db.VideoShare.loadAccountsByShare(video.id, t)
   accountsInvolved.push(byAccount)
 
   return broadcastToFollowers(data, byAccount, accountsInvolved, t)
@@ -40,8 +40,8 @@ export {
 
 // ---------------------------------------------------------------------------
 
-async function updateActivityData (url: string, byAccount: AccountInstance, object: any) {
-  const { to, cc } = await getAudience(byAccount)
+async function updateActivityData (url: string, byAccount: AccountInstance, object: any, t: Transaction) {
+  const { to, cc } = await getAudience(byAccount, t)
   const activity: ActivityUpdate = {
     type: 'Update',
     id: url,