aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers')
-rw-r--r--server/controllers/api/videos/index.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts
index c9334676e..c3d3acd26 100644
--- a/server/controllers/api/videos/index.ts
+++ b/server/controllers/api/videos/index.ts
@@ -22,6 +22,7 @@ import {
22import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' 22import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub'
23import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' 23import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send'
24import { JobQueue } from '../../../lib/job-queue' 24import { JobQueue } from '../../../lib/job-queue'
25import { Redis } from '../../../lib/redis'
25import { 26import {
26 asyncMiddleware, 27 asyncMiddleware,
27 authenticate, 28 authenticate,
@@ -352,7 +353,16 @@ function getVideo (req: express.Request, res: express.Response) {
352async function viewVideo (req: express.Request, res: express.Response) { 353async function viewVideo (req: express.Request, res: express.Response) {
353 const videoInstance = res.locals.video 354 const videoInstance = res.locals.video
354 355
356 const ip = req.ip
357 const exists = await Redis.Instance.isViewExists(ip, videoInstance.uuid)
358 if (exists) {
359 logger.debug('View for ip %s and video %s already exists.', ip, videoInstance.uuid)
360 return res.status(204).end()
361 }
362
355 await videoInstance.increment('views') 363 await videoInstance.increment('views')
364 await Redis.Instance.setView(ip, videoInstance.uuid)
365
356 const serverAccount = await getServerActor() 366 const serverAccount = await getServerActor()
357 367
358 if (videoInstance.isOwned()) { 368 if (videoInstance.isOwned()) {