]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/views/shared/video-viewer-stats.ts
Merge branch 'release/4.2.0' into develop
[github/Chocobozzz/PeerTube.git] / server / lib / views / shared / video-viewer-stats.ts
index fd66fd5c7eee7b82a280775c3e12c01ed99889ff..a56c205590711cfded6fecf32d42c7af2a2458ea 100644 (file)
@@ -10,7 +10,7 @@ import { Redis } from '@server/lib/redis'
 import { VideoModel } from '@server/models/video/video'
 import { LocalVideoViewerModel } from '@server/models/view/local-video-viewer'
 import { LocalVideoViewerWatchSectionModel } from '@server/models/view/local-video-viewer-watch-section'
-import { MVideo } from '@server/types/models'
+import { MVideo, MVideoImmutable } from '@server/types/models'
 import { VideoViewEvent } from '@shared/models'
 
 const lTags = loggerTagsFactory('views')
@@ -41,7 +41,7 @@ export class VideoViewerStats {
   // ---------------------------------------------------------------------------
 
   async addLocalViewer (options: {
-    video: MVideo
+    video: MVideoImmutable
     currentTime: number
     ip: string
     viewEvent?: VideoViewEvent
@@ -64,7 +64,7 @@ export class VideoViewerStats {
   // ---------------------------------------------------------------------------
 
   private async updateLocalViewerStats (options: {
-    video: MVideo
+    video: MVideoImmutable
     ip: string
     currentTime: number
     viewEvent?: VideoViewEvent
@@ -136,6 +136,7 @@ export class VideoViewerStats {
         try {
           await sequelizeTypescript.transaction(async t => {
             const video = await VideoModel.load(stats.videoId, t)
+            if (!video) return
 
             const statsModel = await this.saveViewerStats(video, stats, t)