mirror of https://github.com/Chocobozzz/PeerTube
				
				
				
			Blocked users must not be able to live stream
							parent
							
								
									5f09fde24e
								
							
						
					
					
						commit
						ba3820965f
					
				|  | @ -286,15 +286,16 @@ describe('Test live', function () { | |||
|       rtmpUrl = 'rtmp://' + servers[0].hostname + ':' + servers[0].rtmpPort + '' | ||||
|     }) | ||||
| 
 | ||||
|     async function createLiveWrapper () { | ||||
|       const liveAttributes = { | ||||
|         name: 'user live', | ||||
|         channelId: servers[0].store.channel.id, | ||||
|         privacy: VideoPrivacy.PUBLIC, | ||||
|         saveReplay: false | ||||
|       } | ||||
| 
 | ||||
|       const { uuid } = await commands[0].create({ fields: liveAttributes }) | ||||
|     async function createLiveWrapper (token?: string, channelId?: number) { | ||||
|       const { uuid } = await commands[0].create({ | ||||
|         token, | ||||
|         fields: { | ||||
|           name: 'user live', | ||||
|           channelId: channelId ?? servers[0].store.channel.id, | ||||
|           privacy: VideoPrivacy.PUBLIC, | ||||
|           saveReplay: false | ||||
|         } | ||||
|       }) | ||||
| 
 | ||||
|       const live = await commands[0].get({ videoId: uuid }) | ||||
|       const video = await servers[0].videos.get({ id: uuid }) | ||||
|  | @ -349,6 +350,18 @@ describe('Test live', function () { | |||
|       await testFfmpegStreamError(command, true) | ||||
|     }) | ||||
| 
 | ||||
|     it('Should not allow a stream on if the owner has been blocked', async function () { | ||||
|       this.timeout(60000) | ||||
| 
 | ||||
|       const { token, userId, userChannelId } = await servers[0].users.generate('user1') | ||||
|       liveVideo = await createLiveWrapper(token, userChannelId) | ||||
| 
 | ||||
|       await servers[0].users.banUser({ userId }) | ||||
| 
 | ||||
|       const command = sendRTMPStream({ rtmpBaseUrl: rtmpUrl + '/live', streamKey: liveVideo.streamKey }) | ||||
|       await testFfmpegStreamError(command, true) | ||||
|     }) | ||||
| 
 | ||||
|     it('Should not allow a stream on a live that was deleted', async function () { | ||||
|       this.timeout(60000) | ||||
| 
 | ||||
|  |  | |||
|  | @ -18,7 +18,7 @@ import { VideoLiveSessionModel } from '@server/models/video/video-live-session.j | |||
| import { VideoLiveModel } from '@server/models/video/video-live.js' | ||||
| import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist.js' | ||||
| import { VideoModel } from '@server/models/video/video.js' | ||||
| import { MVideo, MVideoLiveSession, MVideoLiveVideo, MVideoLiveVideoWithSetting } from '@server/types/models/index.js' | ||||
| import { MUser, MVideo, MVideoLiveSession, MVideoLiveVideo, MVideoLiveVideoWithSetting } from '@server/types/models/index.js' | ||||
| import { | ||||
|   ffprobePromise, | ||||
|   getVideoStreamBitrate, | ||||
|  | @ -250,6 +250,12 @@ class LiveManager { | |||
|       return this.abortSession(sessionId) | ||||
|     } | ||||
| 
 | ||||
|     const user = await UserModel.loadByLiveId(videoLive.id) | ||||
|     if (user.blocked) { | ||||
|       logger.warn('User is blocked. Refusing stream %s.', streamKey, lTags(sessionId, video.uuid)) | ||||
|       return this.abortSession(sessionId) | ||||
|     } | ||||
| 
 | ||||
|     if (this.videoSessions.has(video.uuid)) { | ||||
|       logger.warn('Video %s has already a live session. Refusing stream %s.', video.uuid, streamKey, lTags(sessionId, video.uuid)) | ||||
|       return this.abortSession(sessionId) | ||||
|  | @ -295,6 +301,8 @@ class LiveManager { | |||
|       sessionId, | ||||
|       videoLive, | ||||
| 
 | ||||
|       user, | ||||
| 
 | ||||
|       inputLocalUrl, | ||||
|       inputPublicUrl, | ||||
|       fps, | ||||
|  | @ -309,6 +317,8 @@ class LiveManager { | |||
|     sessionId: string | ||||
|     videoLive: MVideoLiveVideoWithSetting | ||||
| 
 | ||||
|     user: MUser | ||||
| 
 | ||||
|     inputLocalUrl: string | ||||
|     inputPublicUrl: string | ||||
| 
 | ||||
|  | @ -318,13 +328,12 @@ class LiveManager { | |||
|     allResolutions: number[] | ||||
|     hasAudio: boolean | ||||
|   }) { | ||||
|     const { sessionId, videoLive } = options | ||||
|     const { sessionId, videoLive, user } = options | ||||
|     const videoUUID = videoLive.Video.uuid | ||||
|     const localLTags = lTags(sessionId, videoUUID) | ||||
| 
 | ||||
|     const liveSession = await this.saveStartingSession(videoLive) | ||||
| 
 | ||||
|     const user = await UserModel.loadByLiveId(videoLive.id) | ||||
|     LiveQuotaStore.Instance.addNewLive(user.id, sessionId) | ||||
| 
 | ||||
|     const muxingSession = new MuxingSession({ | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 Chocobozzz
						Chocobozzz