Skip to content

Commit

Permalink
Fix redundancy federation in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocobozzz committed Dec 17, 2020
1 parent 9e454eb commit 9cfeb3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
9 changes: 7 additions & 2 deletions server/lib/activitypub/send/send-undo.ts
Expand Up @@ -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 })
Expand Down
8 changes: 7 additions & 1 deletion server/lib/activitypub/send/send-update.ts
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion server/models/redundancy/video-redundancy.ts
Expand Up @@ -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 () {
Expand Down

0 comments on commit 9cfeb3c

Please sign in to comment.