const serverActor = await getServerActor()
- await sendCreateView(serverActor, videoInstance, undefined)
+ // Send the event to the origin server
+ // If we own the video, we'll send an update event when we'll process the views (in our job queue)
+ if (videoInstance.isOwned() === false) {
+ await sendCreateView(serverActor, videoInstance, undefined)
+ }
return res.status(204).end()
}
import { Redis } from '../../redis'
import { createOrUpdateCacheFile } from '../cache-file'
import { immutableAssign } from '../../../tests/utils'
-import { getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url'
+import { getVideoDislikeActivityPubUrl } from '../url'
+import { VideoModel } from '../../../models/video/video'
async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) {
const activityObject = activity.object
async function processCreateView (byActor: ActorModel, activity: ActivityCreate) {
const view = activity.object as ViewObject
- const options = {
- videoObject: view.object,
- fetchType: 'only-video' as 'only-video'
- }
- const { video } = await getOrCreateVideoAndAccountAndChannel(options)
+ const video = await VideoModel.loadByUrl(view.object)
+ if (!video || video.isOwned() === false) return
await Redis.Instance.addVideoView(video.id)
-
- if (video.isOwned()) {
- // Don't resend the activity to the sender
- const exceptions = [ byActor ]
- await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
- }
}
async function processCacheFile (byActor: ActorModel, activity: ActivityCreate) {
import { VideoModel } from '../../../models/video/video'
import { VideoViewModel } from '../../../models/video/video-views'
import { isTestInstance } from '../../../helpers/core-utils'
+import { federateVideoIfNeeded } from '../../activitypub'
-async function processVideosViewsViews () {
+async function processVideosViews () {
const lastHour = new Date()
// In test mode, we run this function multiple times per hour, so we don't want the values of the previous hour
views,
videoId
})
+
+ const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(videoId)
+ await federateVideoIfNeeded(video, false)
} catch (err) {
logger.debug('Cannot create video views for video %d in hour %d. Maybe the video does not exist anymore?', videoId, hour)
}
// ---------------------------------------------------------------------------
export {
- processVideosViewsViews
+ processVideosViews
}
import { processVideoFile, processVideoFileImport, VideoFileImportPayload, VideoFilePayload } from './handlers/video-file'
import { ActivitypubFollowPayload, processActivityPubFollow } from './handlers/activitypub-follow'
import { processVideoImport, VideoImportPayload } from './handlers/video-import'
-import { processVideosViewsViews } from './handlers/video-views'
+import { processVideosViews } from './handlers/video-views'
type CreateJobArgument =
{ type: 'activitypub-http-broadcast', payload: ActivitypubHttpBroadcastPayload } |
'video-file': processVideoFile,
'email': processEmail,
'video-import': processVideoImport,
- 'videos-views': processVideosViewsViews
+ 'videos-views': processVideosViews
}
const jobTypes: JobType[] = [