From 6d8135d1e38d48c566c3fe3308259fbf682168bb Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Tue, 7 Jul 2026 21:25:27 -0400 Subject: [PATCH] Updated scheduler to ensure client knows channel streamtype at time of clicking 'go-live' button. --- src/app/channel/connectedUser.js | 4 +-- src/app/channel/media/queue.js | 31 ++++++++++++++++++- www/js/channel/channel.js | 7 +++++ .../channel/panels/queuePanel/queuePanel.js | 12 +++++++ 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/app/channel/connectedUser.js b/src/app/channel/connectedUser.js index bec1409..5347cb4 100644 --- a/src/app/channel/connectedUser.js +++ b/src/app/channel/connectedUser.js @@ -197,8 +197,6 @@ class connectedUser{ chanDB = await channelModel.findOne({name: this.channel.name}); } - //If our perm map is un-initiated - //can't set this in constructor easily since it's asyncornous //need to wait for it to complete before sending this off, but shouldnt re-do the wait for later connections if(this.permMap == null){ //Grab perm map @@ -238,7 +236,7 @@ class connectedUser{ const chatBuffer = this.channel.chatBuffer.buffer; //Send off the metadata to our user's clients - this.emit("clientMetadata", {user: userObj, flairList, queueLock, chatBuffer}); + this.emit("clientMetadata", {user: userObj, flairList, queueLock, chatBuffer, streamType: chanDB.settings.streamType}); } /** diff --git a/src/app/channel/media/queue.js b/src/app/channel/media/queue.js index 597c062..ac2eb75 100644 --- a/src/app/channel/media/queue.js +++ b/src/app/channel/media/queue.js @@ -120,6 +120,7 @@ class queue{ socket.on("move", (data) => {this.moveMedia(socket, data)}); socket.on("lock", () => {this.toggleLock(socket)}); socket.on("goLive", (data) => {this.goLive(socket, data)}); + socket.on("getStreamType", (data) => {this.getStreamType(socket)}); //If debug mode is enabled if(config.debug){ @@ -357,6 +358,18 @@ class queue{ throw loggerUtils.exceptionSmith(`Unable to find channel document ${this.channel.name} while queue item!`, "queue"); } + + //If the user doesn't have permission to be doing this shit + if(!((!this.locked && await chanDB.permCheck(socket.user, 'scheduleMedia')) || await chanDB.permCheck(socket.user, 'scheduleAdmin'))){ + //Fuggettabouttit! + return; + } + + if(chanDB.settings.streamType == "webrtc"){ + console.log("WEBRTC ENABLED, BAILING!"); + return; + } + //If something is playing if(this.nowPlaying != null){ //Capture currently playing object @@ -403,7 +416,7 @@ class queue{ ); //Validate mode input, and default to overwrite - this.liveMode = (data.mode == "pushback") ? "pushback" : "overwrite"; + this.liveMode = (data != null && data.mode == "pushback") ? "pushback" : "overwrite"; //Throw stream lock this.streamLock = true; @@ -415,6 +428,22 @@ class queue{ } } + /** + * Returns current channel stream type upon request + * @param {Socket} socket - Socket we received the request from + */ + async getStreamType(socket){ + try{ + //Get the current channel from the database + const chanDB = await channelModel.findOne({name: socket.chan}); + + //Send streamtype back down to user (Not perm checking for something someone can figure out by looking at a running livestream) + socket.emit("streamType", {streamType: chanDB.settings.streamType}); + }catch(err){ + return loggerUtils.socketExceptionHandler(socket, err); + } + } + async dumpQueue(socket, data){ //If we somehow got here while config.debug is disabled, or the user isn't allowed to preform server-side debugging if(!(config.debug && await permissionModel.permCheck(socket.user, "debug"))){ diff --git a/www/js/channel/channel.js b/www/js/channel/channel.js index 5663d48..840b939 100644 --- a/www/js/channel/channel.js +++ b/www/js/channel/channel.js @@ -117,6 +117,10 @@ class channel{ this.queueLock = data.locked; }); + this.socket.on("streamType", (data) => { + this.streamType = data.streamType; + }); + this.queueBroadcastSocket.on("queue", (data) => { this.queue = new Map(data.queue); }); @@ -146,6 +150,9 @@ class channel{ //Store queue lock status this.queueLock = data.queueLock; + + //Store streamType + this.streamType = data.streamType; } /** diff --git a/www/js/channel/panels/queuePanel/queuePanel.js b/www/js/channel/panels/queuePanel/queuePanel.js index c254caa..7f258e3 100644 --- a/www/js/channel/panels/queuePanel/queuePanel.js +++ b/www/js/channel/panels/queuePanel/queuePanel.js @@ -54,6 +54,8 @@ class queuePanel extends panelObj{ */ this.playlistManager = new playlistManager(client, panelDocument, this); + this.streamType = ""; + //Define non-input event listeners this.defineListeners(); } @@ -65,6 +67,9 @@ class queuePanel extends panelObj{ //Call derived doc switch function super.docSwitch(); + //Request Channel Stream Type + this.client.socket.emit('getStreamType'); + //Get queue div this.queue = this.panelDocument.querySelector('#queue'); //Get queue container @@ -243,6 +248,10 @@ class queuePanel extends panelObj{ } } + handleStreamType(data){ + + } + /* queue control button functions */ /** @@ -269,6 +278,9 @@ class queuePanel extends panelObj{ * @param {Event} event - Event passed down from Event Listener */ toggleGoLive(event){ + //Request stream type from the server Just-InCaseā„¢ + client.socket.emit('getStreamType'); + //If we're not livestreaming if(client.player.mediaHandler.type != "livehls"){ //If the div is hidden