X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Factivitypub%2Fsend%2Fsend-update.ts;h=bcf6e15696851c904b936fb33d2966c59b98e705;hb=dc48fdbe68e9dd3a3a6028181e61d8595d98e654;hp=cb500bd347e9a96ec60c5a8e641a29d54a89d068;hpb=7cd1b12c19d0589d1d692ed0571ca0800f028aea;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index cb500bd34..bcf6e1569 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts @@ -9,7 +9,6 @@ import { broadcastToFollowers, sendVideoRelatedActivity } from './utils' import { audiencify, getActorsInvolvedInVideo, getAudience } from '../audience' import { logger } from '../../../helpers/logger' import { VideoPlaylistPrivacy } from '../../../../shared/models/videos/playlist/video-playlist-privacy.model' -import { getServerActor } from '../../../helpers/utils' import { MAccountDefault, MActor, @@ -19,7 +18,8 @@ import { MVideoAPWithoutCaption, MVideoPlaylistFull, MVideoRedundancyVideo -} from '../../../typings/models' +} from '../../../types/models' +import { getServerActor } from '@server/models/application/application' async function sendUpdateVideo (videoArg: MVideoAPWithoutCaption, t: Transaction, overrodeByActor?: MActor) { const video = videoArg as MVideoAP @@ -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() @@ -84,7 +90,7 @@ async function sendUpdateCacheFile (byActor: MActorLight, redundancyModel: MVide return buildUpdateActivity(url, byActor, redundancyObject, audience) } - return sendVideoRelatedActivity(activityBuilder, { byActor, video }) + return sendVideoRelatedActivity(activityBuilder, { byActor, video, contextType: 'CacheFile' }) } async function sendUpdateVideoPlaylist (videoPlaylist: MVideoPlaylistFull, t: Transaction) {