1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-04 02:09:37 +02:00

Correctly forward video related activities

This commit is contained in:
Chocobozzz 2018-05-31 10:23:56 +02:00
parent 3f9b33b02b
commit 9588d4f49b
No known key found for this signature in database
GPG key ID: 583A612D890159BE
6 changed files with 43 additions and 18 deletions

View file

@ -8,7 +8,7 @@ import { AccountModel } from '../../../models/account/account'
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
import { ActorModel } from '../../../models/activitypub/actor'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { forwardActivity } from '../send/utils'
import { forwardVideoRelatedActivity } from '../send/utils'
import { getOrCreateAccountAndVideoAndChannel } from '../videos'
import { VideoShareModel } from '../../../models/video/video-share'
@ -67,7 +67,8 @@ async function undoLike (actorUrl: string, activity: ActivityUndo) {
if (video.isOwned()) {
// Don't resend the activity to the sender
const exceptions = [ byAccount.Actor ]
await forwardActivity(activity, t, exceptions)
await forwardVideoRelatedActivity(activity, t, exceptions, video)
}
})
}
@ -99,7 +100,8 @@ async function undoDislike (actorUrl: string, activity: ActivityUndo) {
if (video.isOwned()) {
// Don't resend the activity to the sender
const exceptions = [ byAccount.Actor ]
await forwardActivity(activity, t, exceptions)
await forwardVideoRelatedActivity(activity, t, exceptions, video)
}
})
}
@ -138,11 +140,19 @@ function processUndoAnnounce (actorUrl: string, announceActivity: ActivityAnnoun
function undoAnnounce (actorUrl: string, announceActivity: ActivityAnnounce) {
return sequelizeTypescript.transaction(async t => {
const byAccount = await AccountModel.loadByUrl(actorUrl, t)
if (!byAccount) throw new Error('Unknown account ' + actorUrl)
const share = await VideoShareModel.loadByUrl(announceActivity.id, t)
if (!share) throw new Error(`'Unknown video share ${announceActivity.id}.`)
await share.destroy({ transaction: t })
return undefined
if (share.Video.isOwned()) {
// Don't resend the activity to the sender
const exceptions = [ byAccount.Actor ]
await forwardVideoRelatedActivity(announceActivity, t, exceptions, share.Video)
}
})
}