aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/peertube-socket.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-11-04 15:31:32 +0100
committerChocobozzz <chocobozzz@cpy.re>2020-11-09 15:33:04 +0100
commitbd54ad1953ee0484ba90cf5f588f4c282048f368 (patch)
tree36e84ed92589a8775bc18e1b056f6b8de14bf2bb /server/lib/peertube-socket.ts
parent68e70a745b2010cd0199864a2addd60d8f99c732 (diff)
downloadPeerTube-bd54ad1953ee0484ba90cf5f588f4c282048f368.tar.gz
PeerTube-bd54ad1953ee0484ba90cf5f588f4c282048f368.tar.zst
PeerTube-bd54ad1953ee0484ba90cf5f588f4c282048f368.zip
Add live notification tests
Diffstat (limited to 'server/lib/peertube-socket.ts')
-rw-r--r--server/lib/peertube-socket.ts14
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'
6import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models' 6import { LiveVideoEventPayload, LiveVideoEventType } from '@shared/models'
7import { logger } from '../helpers/logger' 7import { logger } from '../helpers/logger'
8import { authenticateSocket } from '../middlewares' 8import { authenticateSocket } from '../middlewares'
9import { isIdValid } from '@server/helpers/custom-validators/misc'
9 10
10class PeerTubeSocket { 11class 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