Fix redundancy federation in some cases

pull/3489/head
Chocobozzz 2020-12-17 09:23:57 +01:00
parent 9e454eba57
commit 9cfeb3cf98
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 17 additions and 4 deletions

View File

@ -79,8 +79,13 @@ async function sendUndoDislike (byActor: MActor, video: MVideoAccountLight, t: T
async function sendUndoCacheFile (byActor: MActor, redundancyModel: MVideoRedundancyVideo, t: Transaction) {
logger.info('Creating job to undo cache file %s.', redundancyModel.url)
const videoId = redundancyModel.getVideo().id
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
const associatedVideo = redundancyModel.getVideo()
if (!associatedVideo) {
logger.warn('Cannot send undo activity for redundancy %s: no video files associated.', redundancyModel.url)
return
}
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id)
const createActivity = buildCreateActivity(redundancyModel.url, byActor, redundancyModel.toActivityPubObject())
return sendUndoVideoRelatedActivity({ byActor, video, url: redundancyModel.url, activity: createActivity, transaction: t })

View File

@ -75,7 +75,13 @@ async function sendUpdateActor (accountOrChannel: MChannelDefault | MAccountDefa
async function sendUpdateCacheFile (byActor: MActorLight, redundancyModel: MVideoRedundancyVideo) {
logger.info('Creating job to update cache file %s.', redundancyModel.url)
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(redundancyModel.getVideo().id)
const associatedVideo = redundancyModel.getVideo()
if (!associatedVideo) {
logger.warn('Cannot send update activity for redundancy %s: no video files associated.', redundancyModel.url)
return
}
const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(associatedVideo.id)
const activityBuilder = (audience: ActivityAudience) => {
const redundancyObject = redundancyModel.toActivityPubObject()

View File

@ -651,7 +651,9 @@ export class VideoRedundancyModel extends Model {
getVideo () {
if (this.VideoFile) return this.VideoFile.Video
return this.VideoStreamingPlaylist.Video
if (this.VideoStreamingPlaylist.Video) return this.VideoStreamingPlaylist.Video
return undefined
}
isOwned () {