1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 10:49:28 +02:00

Put activity pub sends inside transactions

This commit is contained in:
Chocobozzz 2017-11-30 11:31:15 +01:00
parent 5cd8054542
commit 25ed141c7c
No known key found for this signature in database
GPG key ID: 583A612D890159BE
21 changed files with 144 additions and 113 deletions

View file

@ -8,15 +8,22 @@ async function sendAddVideo (video: VideoInstance, t: Transaction) {
const byAccount = video.VideoChannel.Account
const videoObject = video.toActivityPubObject()
const data = await addActivityData(video.url, byAccount, video, video.VideoChannel.url, videoObject)
const data = await addActivityData(video.url, byAccount, video, video.VideoChannel.url, videoObject, t)
return broadcastToFollowers(data, byAccount, [ byAccount ], t)
}
async function addActivityData (url: string, byAccount: AccountInstance, video: VideoInstance, target: string, object: any) {
async function addActivityData (
url: string,
byAccount: AccountInstance,
video: VideoInstance,
target: string,
object: any,
t: Transaction
) {
const videoPublic = video.privacy === VideoPrivacy.PUBLIC
const { to, cc } = await getAudience(byAccount, videoPublic)
const { to, cc } = await getAudience(byAccount, t, videoPublic)
const activity: ActivityAdd = {
type: 'Add',
id: url,