aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/send/send-undo.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-30 11:31:15 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-30 11:31:15 +0100
commit25ed141c7c7631ef21d8764c1163fbf8a6591391 (patch)
tree8f556181a3369e7e4938d612d91be0af813e5067 /server/lib/activitypub/send/send-undo.ts
parent5cd80545422bba855cc9a730a2e13cc9d982c34b (diff)
downloadPeerTube-25ed141c7c7631ef21d8764c1163fbf8a6591391.tar.gz
PeerTube-25ed141c7c7631ef21d8764c1163fbf8a6591391.tar.zst
PeerTube-25ed141c7c7631ef21d8764c1163fbf8a6591391.zip
Put activity pub sends inside transactions
Diffstat (limited to 'server/lib/activitypub/send/send-undo.ts')
-rw-r--r--server/lib/activitypub/send/send-undo.ts31
1 files changed, 16 insertions, 15 deletions
diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts
index 878acd21e..2f5e6998e 100644
--- a/server/lib/activitypub/send/send-undo.ts
+++ b/server/lib/activitypub/send/send-undo.ts
@@ -29,8 +29,8 @@ async function sendUndoFollow (accountFollow: AccountFollowInstance, t: Transact
29 const followUrl = getAccountFollowActivityPubUrl(accountFollow) 29 const followUrl = getAccountFollowActivityPubUrl(accountFollow)
30 const undoUrl = getUndoActivityPubUrl(followUrl) 30 const undoUrl = getUndoActivityPubUrl(followUrl)
31 31
32 const object = await followActivityData(followUrl, me, following) 32 const object = followActivityData(followUrl, me, following)
33 const data = await undoActivityData(undoUrl, me, object) 33 const data = await undoActivityData(undoUrl, me, object, t)
34 34
35 return unicastTo(data, me, following.inboxUrl, t) 35 return unicastTo(data, me, following.inboxUrl, t)
36} 36}
@@ -39,10 +39,10 @@ async function sendUndoLikeToOrigin (byAccount: AccountInstance, video: VideoIns
39 const likeUrl = getVideoLikeActivityPubUrl(byAccount, video) 39 const likeUrl = getVideoLikeActivityPubUrl(byAccount, video)
40 const undoUrl = getUndoActivityPubUrl(likeUrl) 40 const undoUrl = getUndoActivityPubUrl(likeUrl)
41 41
42 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video) 42 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t)
43 const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) 43 const audience = getOriginVideoAudience(video, accountsInvolvedInVideo)
44 const object = await likeActivityData(likeUrl, byAccount, video) 44 const object = await likeActivityData(likeUrl, byAccount, video, t)
45 const data = await undoActivityData(undoUrl, byAccount, object, audience) 45 const data = await undoActivityData(undoUrl, byAccount, object, t, audience)
46 46
47 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) 47 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
48} 48}
@@ -51,10 +51,10 @@ async function sendUndoLikeToVideoFollowers (byAccount: AccountInstance, video:
51 const likeUrl = getVideoLikeActivityPubUrl(byAccount, video) 51 const likeUrl = getVideoLikeActivityPubUrl(byAccount, video)
52 const undoUrl = getUndoActivityPubUrl(likeUrl) 52 const undoUrl = getUndoActivityPubUrl(likeUrl)
53 53
54 const toAccountsFollowers = await getAccountsInvolvedInVideo(video) 54 const toAccountsFollowers = await getAccountsInvolvedInVideo(video, t)
55 const audience = getObjectFollowersAudience(toAccountsFollowers) 55 const audience = getObjectFollowersAudience(toAccountsFollowers)
56 const object = await likeActivityData(likeUrl, byAccount, video) 56 const object = await likeActivityData(likeUrl, byAccount, video, t)
57 const data = await undoActivityData(undoUrl, byAccount, object, audience) 57 const data = await undoActivityData(undoUrl, byAccount, object, t, audience)
58 58
59 const followersException = [ byAccount ] 59 const followersException = [ byAccount ]
60 return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException) 60 return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException)
@@ -64,12 +64,12 @@ async function sendUndoDislikeToOrigin (byAccount: AccountInstance, video: Video
64 const dislikeUrl = getVideoDislikeActivityPubUrl(byAccount, video) 64 const dislikeUrl = getVideoDislikeActivityPubUrl(byAccount, video)
65 const undoUrl = getUndoActivityPubUrl(dislikeUrl) 65 const undoUrl = getUndoActivityPubUrl(dislikeUrl)
66 66
67 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video) 67 const accountsInvolvedInVideo = await getAccountsInvolvedInVideo(video, t)
68 const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) 68 const audience = getOriginVideoAudience(video, accountsInvolvedInVideo)
69 const dislikeActivity = createDislikeActivityData(byAccount, video) 69 const dislikeActivity = createDislikeActivityData(byAccount, video)
70 const object = await createActivityData(undoUrl, byAccount, dislikeActivity, audience) 70 const object = await createActivityData(undoUrl, byAccount, dislikeActivity, t, audience)
71 71
72 const data = await undoActivityData(undoUrl, byAccount, object) 72 const data = await undoActivityData(undoUrl, byAccount, object, t)
73 73
74 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t) 74 return unicastTo(data, byAccount, video.VideoChannel.Account.sharedInboxUrl, t)
75} 75}
@@ -79,11 +79,11 @@ async function sendUndoDislikeToVideoFollowers (byAccount: AccountInstance, vide
79 const undoUrl = getUndoActivityPubUrl(dislikeUrl) 79 const undoUrl = getUndoActivityPubUrl(dislikeUrl)
80 80
81 const dislikeActivity = createDislikeActivityData(byAccount, video) 81 const dislikeActivity = createDislikeActivityData(byAccount, video)
82 const object = await createActivityData(undoUrl, byAccount, dislikeActivity) 82 const object = await createActivityData(undoUrl, byAccount, dislikeActivity, t)
83 83
84 const data = await undoActivityData(undoUrl, byAccount, object) 84 const data = await undoActivityData(undoUrl, byAccount, object, t)
85 85
86 const toAccountsFollowers = await getAccountsInvolvedInVideo(video) 86 const toAccountsFollowers = await getAccountsInvolvedInVideo(video, t)
87 87
88 const followersException = [ byAccount ] 88 const followersException = [ byAccount ]
89 return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException) 89 return broadcastToFollowers(data, byAccount, toAccountsFollowers, t, followersException)
@@ -105,10 +105,11 @@ async function undoActivityData (
105 url: string, 105 url: string,
106 byAccount: AccountInstance, 106 byAccount: AccountInstance,
107 object: ActivityFollow | ActivityLike | ActivityCreate, 107 object: ActivityFollow | ActivityLike | ActivityCreate,
108 t: Transaction,
108 audience?: ActivityAudience 109 audience?: ActivityAudience
109) { 110) {
110 if (!audience) { 111 if (!audience) {
111 audience = await getAudience(byAccount) 112 audience = await getAudience(byAccount, t)
112 } 113 }
113 114
114 const activity: ActivityUndo = { 115 const activity: ActivityUndo = {