diff options
Diffstat (limited to 'server/lib/peertube-socket.ts')
-rw-r--r-- | server/lib/peertube-socket.ts | 14 |
1 files changed, 12 insertions, 2 deletions
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' | |||
6 | import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' | 6 | import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' |
7 | import { logger } from '../helpers/logger' | 7 | import { logger } from '../helpers/logger' |
8 | import { authenticateSocket } from '../middlewares' | 8 | import { authenticateSocket } from '../middlewares' |
9 | import { isIdValid } from '@server/helpers/custom-validators/misc' | ||
9 | 10 | ||
10 | class PeerTubeSocket { | 11 | class PeerTubeSocket { |
11 | 12 | ||
@@ -39,8 +40,17 @@ class PeerTubeSocket { | |||
39 | 40 | ||
40 | this.liveVideosNamespace = io.of('/live-videos') | 41 | this.liveVideosNamespace = io.of('/live-videos') |
41 | .on('connection', socket => { | 42 | .on('connection', socket => { |
42 | socket.on('subscribe', ({ videoId }) => socket.join(videoId)) | 43 | socket.on('subscribe', ({ videoId }) => { |
43 | socket.on('unsubscribe', ({ videoId }) => socket.leave(videoId)) | 44 | if (!isIdValid(videoId)) return |
45 | |||
46 | socket.join(videoId) | ||
47 | }) | ||
48 | |||
49 | socket.on('unsubscribe', ({ videoId }) => { | ||
50 | if (!isIdValid(videoId)) return | ||
51 | |||
52 | socket.leave(videoId) | ||
53 | }) | ||
44 | }) | 54 | }) |
45 | } | 55 | } |
46 | 56 | ||