X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fredis.ts;h=257cce1418b6338a25c4b6c65fb43ad97e8006c0;hb=aaedadd5386b580e9ebac540201399c25c7f0b0f;hp=a075eee2d900e9765f96d04578e2a167ecb90db4;hpb=e9c5f123383e461a890c95368dce6f79d3b84660;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/redis.ts b/server/lib/redis.ts index a075eee2d..257cce141 100644 --- a/server/lib/redis.ts +++ b/server/lib/redis.ts @@ -7,7 +7,7 @@ import { USER_EMAIL_VERIFY_LIFETIME, USER_PASSWORD_RESET_LIFETIME, USER_PASSWORD_CREATE_LIFETIME, - VIDEO_VIEW_LIFETIME, + VIEW_LIFETIME, WEBSERVER, TRACKER_RATE_LIMITS } from '../initializers/constants' @@ -118,8 +118,12 @@ class Redis { /* ************ Views per IP ************ */ - setIPVideoView (ip: string, videoUUID: string) { - return this.setValue(this.generateViewKey(ip, videoUUID), '1', VIDEO_VIEW_LIFETIME) + setIPVideoView (ip: string, videoUUID: string, isLive: boolean) { + const lifetime = isLive + ? VIEW_LIFETIME.LIVE + : VIEW_LIFETIME.VIDEO + + return this.setValue(this.generateViewKey(ip, videoUUID), '1', lifetime) } async doesVideoIPViewExist (ip: string, videoUUID: string) { @@ -211,7 +215,7 @@ class Redis { } private generateVideoViewKey (videoId: number, hour?: number) { - if (!hour) hour = new Date().getHours() + if (hour === undefined || hour === null) hour = new Date().getHours() return `video-view-${videoId}-h${hour}` }