- const { video } = await getOrCreateVideoAndAccountAndChannel(videoObject.id)
- const channelActor = await getOrCreateVideoChannel(videoObject)
+ const { video, created } = await getOrCreateVideoAndAccountAndChannel({
+ videoObject: videoObject.id,
+ allowRefresh: false,
+ fetchType: 'all'
+ })
+ // We did not have this video, it has been created so no need to update
+ if (created) return
+
+ // Load new channel
+ const channelActor = await getOrCreateVideoChannelFromVideoObject(videoObject)
+
+ const account = actor.Account as MAccountIdActor
+ account.Actor = actor
+
+ const updateOptions = {
+ video,
+ videoObject,
+ account,
+ channel: channelActor.VideoChannel,
+ overrideTo: activity.to
+ }
+ return updateVideoFromAP(updateOptions)
+}
+
+async function processUpdateCacheFile (byActor: MActorSignature, activity: ActivityUpdate) {
+ if (await isRedundancyAccepted(activity, byActor) !== true) return
+
+ const cacheFileObject = activity.object as CacheFileObject
+
+ if (!isCacheFileObjectValid(cacheFileObject)) {
+ logger.debug('Cache file object sent by update is not valid.', { cacheFileObject })
+ return undefined
+ }