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 | |
parent | 68e70a745b2010cd0199864a2addd60d8f99c732 (diff) | |
download | PeerTube-bd54ad1953ee0484ba90cf5f588f4c282048f368.tar.gz PeerTube-bd54ad1953ee0484ba90cf5f588f4c282048f368.tar.zst PeerTube-bd54ad1953ee0484ba90cf5f588f4c282048f368.zip |
Add live notification tests
Diffstat (limited to 'server/lib')
-rw-r--r-- | server/lib/live-manager.ts | 2 | ||||
-rw-r--r-- | server/lib/peertube-socket.ts | 14 |
2 files changed, 13 insertions, 3 deletions
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 { | |||
244 | size: -1, | 244 | size: -1, |
245 | extname: '.ts', | 245 | extname: '.ts', |
246 | infoHash: null, | 246 | infoHash: null, |
247 | fps: -1, | 247 | fps, |
248 | videoStreamingPlaylistId: playlist.id | 248 | videoStreamingPlaylistId: playlist.id |
249 | }).catch(err => { | 249 | }).catch(err => { |
250 | logger.error('Cannot create file for live streaming.', { err }) | 250 | 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' | |||
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 | ||