From bd54ad1953ee0484ba90cf5f588f4c282048f368 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 4 Nov 2020 15:31:32 +0100 Subject: Add live notification tests --- server/lib/live-manager.ts | 2 +- server/lib/peertube-socket.ts | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'server/lib') diff --git a/server/lib/live-manager.ts b/server/lib/live-manager.ts index 6eb05c9d6..d253d06fc 100644 --- a/server/lib/live-manager.ts +++ b/server/lib/live-manager.ts @@ -244,7 +244,7 @@ class LiveManager { size: -1, extname: '.ts', infoHash: null, - fps: -1, + fps, videoStreamingPlaylistId: playlist.id }).catch(err => { logger.error('Cannot create file for live streaming.', { err }) diff --git a/server/lib/peertube-socket.ts b/server/lib/peertube-socket.ts index c918a8685..c4df399ca 100644 --- a/server/lib/peertube-socket.ts +++ b/server/lib/peertube-socket.ts @@ -6,6 +6,7 @@ import { UserNotificationModelForApi } from '@server/types/models/user' import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' import { logger } from '../helpers/logger' import { authenticateSocket } from '../middlewares' +import { isIdValid } from '@server/helpers/custom-validators/misc' class PeerTubeSocket { @@ -39,8 +40,17 @@ class PeerTubeSocket { this.liveVideosNamespace = io.of('/live-videos') .on('connection', socket => { - socket.on('subscribe', ({ videoId }) => socket.join(videoId)) - socket.on('unsubscribe', ({ videoId }) => socket.leave(videoId)) + socket.on('subscribe', ({ videoId }) => { + if (!isIdValid(videoId)) return + + socket.join(videoId) + }) + + socket.on('unsubscribe', ({ videoId }) => { + if (!isIdValid(videoId)) return + + socket.leave(videoId) + }) }) } -- cgit v1.2.3