]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/process/process-view.ts
Refactor getOrCreateAPVideo
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / process / process-view.ts
index efceb21a207f64ecef6184f40dec2d8e8f807208..c2d41dd2845fe2e629416795eb81863e07d3e91c 100644 (file)
@@ -1,4 +1,4 @@
-import { getOrCreateVideoAndAccountAndChannel } from '../videos'
+import { getOrCreateAPVideo } from '../videos'
 import { forwardVideoRelatedActivity } from '../send/utils'
 import { Redis } from '../../redis'
 import { ActivityCreate, ActivityView, ViewObject } from '../../../../shared/models/activitypub'
@@ -29,7 +29,11 @@ async function processCreateView (activity: ActivityView | ActivityCreate, byAct
     fetchType: 'only-video' as 'only-video',
     allowRefresh: false as false
   }
-  const { video } = await getOrCreateVideoAndAccountAndChannel(options)
+  const { video } = await getOrCreateAPVideo(options)
+
+  if (!video.isLive) {
+    await Redis.Instance.addVideoView(video.id)
+  }
 
   if (video.isOwned()) {
     // Our live manager will increment the counter and send the view to followers
@@ -38,8 +42,6 @@ async function processCreateView (activity: ActivityView | ActivityCreate, byAct
       return
     }
 
-    await Redis.Instance.addVideoView(video.id)
-
     // Forward the view but don't resend the activity to the sender
     const exceptions = [ byActor ]
     await forwardVideoRelatedActivity(activity, undefined, exceptions, video)