diff options
author | Chocobozzz <me@florianbigard.com> | 2020-11-04 15:31:32 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2020-11-09 15:33:04 +0100 |
commit | bd54ad1953ee0484ba90cf5f588f4c282048f368 (patch) | |
tree | 36e84ed92589a8775bc18e1b056f6b8de14bf2bb /server/lib/peertube-socket.ts | |
parent | 68e70a745b2010cd0199864a2addd60d8f99c732 (diff) | |
download | PeerTube-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.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 | ||