aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/views/shared/video-viewer-counters.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-06-17 14:34:37 +0200
committerChocobozzz <me@florianbigard.com>2022-06-17 14:56:16 +0200
commitaa2ce188d102ab38452df316d06286040b5d9075 (patch)
tree100e639f21e9798d811639aa2e20abfa4c8d2bbf /server/lib/views/shared/video-viewer-counters.ts
parentfba911e2c89708a166636e3a93fcd8fcbc3de7e1 (diff)
downloadPeerTube-aa2ce188d102ab38452df316d06286040b5d9075.tar.gz
PeerTube-aa2ce188d102ab38452df316d06286040b5d9075.tar.zst
PeerTube-aa2ce188d102ab38452df316d06286040b5d9075.zip
Optimize view endpoint
Diffstat (limited to 'server/lib/views/shared/video-viewer-counters.ts')
-rw-r--r--server/lib/views/shared/video-viewer-counters.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/server/lib/views/shared/video-viewer-counters.ts b/server/lib/views/shared/video-viewer-counters.ts
index 999ab7d8d..587621320 100644
--- a/server/lib/views/shared/video-viewer-counters.ts
+++ b/server/lib/views/shared/video-viewer-counters.ts
@@ -5,7 +5,7 @@ import { sendView } from '@server/lib/activitypub/send/send-view'
5import { PeerTubeSocket } from '@server/lib/peertube-socket' 5import { PeerTubeSocket } from '@server/lib/peertube-socket'
6import { getServerActor } from '@server/models/application/application' 6import { getServerActor } from '@server/models/application/application'
7import { VideoModel } from '@server/models/video/video' 7import { VideoModel } from '@server/models/video/video'
8import { MVideo } from '@server/types/models' 8import { MVideo, MVideoImmutable } from '@server/types/models'
9import { buildUUID, sha256 } from '@shared/extra-utils' 9import { buildUUID, sha256 } from '@shared/extra-utils'
10 10
11const lTags = loggerTagsFactory('views') 11const lTags = loggerTagsFactory('views')
@@ -33,7 +33,7 @@ export class VideoViewerCounters {
33 // --------------------------------------------------------------------------- 33 // ---------------------------------------------------------------------------
34 34
35 async addLocalViewer (options: { 35 async addLocalViewer (options: {
36 video: MVideo 36 video: MVideoImmutable
37 ip: string 37 ip: string
38 }) { 38 }) {
39 const { video, ip } = options 39 const { video, ip } = options
@@ -86,7 +86,7 @@ export class VideoViewerCounters {
86 // --------------------------------------------------------------------------- 86 // ---------------------------------------------------------------------------
87 87
88 private async addViewerToVideo (options: { 88 private async addViewerToVideo (options: {
89 video: MVideo 89 video: MVideoImmutable
90 viewerId: string 90 viewerId: string
91 viewerExpires?: Date 91 viewerExpires?: Date
92 }) { 92 }) {
@@ -162,7 +162,7 @@ export class VideoViewerCounters {
162 return sha256(this.salt + '-' + ip + '-' + videoUUID) 162 return sha256(this.salt + '-' + ip + '-' + videoUUID)
163 } 163 }
164 164
165 private async federateViewerIfNeeded (video: MVideo, viewer: Viewer) { 165 private async federateViewerIfNeeded (video: MVideoImmutable, viewer: Viewer) {
166 // Federate the viewer if it's been a "long" time we did not 166 // Federate the viewer if it's been a "long" time we did not
167 const now = new Date().getTime() 167 const now = new Date().getTime()
168 const federationLimit = now - (VIEW_LIFETIME.VIEWER_COUNTER / 2) 168 const federationLimit = now - (VIEW_LIFETIME.VIEWER_COUNTER / 2)