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/src/schemas/channel/channelSchema.js b/src/schemas/channel/channelSchema.js
index b6df0b1..8bfa484 100644
--- a/src/schemas/channel/channelSchema.js
+++ b/src/schemas/channel/channelSchema.js
@@ -35,6 +35,11 @@ const chatSchema = require('./chatSchema');
//Utils
const { exceptionHandler, errorHandler } = require('../../utils/loggerUtils');
+/**
+ * "Enum" for emote type property
+ */
+const streamMethodEnum = ["webrtc","hls"];
+
/**
* DB Schema for Documents containing de-hydrated representations of Canopy Stream/Chat Channels
*/
@@ -71,6 +76,12 @@ const channelSchema = new mongoose.Schema({
streamURL: {
type: mongoose.SchemaTypes.String,
default: ''
+ },
+ streamType: {
+ type: mongoose.SchemaTypes.String,
+ enum: streamMethodEnum,
+ default: streamMethodEnum[0]
+
}
},
permissions: {
diff --git a/src/validators/channelValidator.js b/src/validators/channelValidator.js
index 92ef4b5..9c87f55 100644
--- a/src/validators/channelValidator.js
+++ b/src/validators/channelValidator.js
@@ -20,15 +20,6 @@ const { checkSchema, checkExact } = require('express-validator');
//local imports
const accountValidator = require('./accountValidator');
-module.exports = {
-
- settingsMap: () => checkExact(checkSchema({
- 'settingsMap.hidden': {
- optional: true,
- isBoolean: true,
- } }))
-}
-
module.exports.name = function(field = 'name'){
return checkSchema({
[field]: {
@@ -89,6 +80,13 @@ module.exports.settingsMap = function(){
}
},
errorMessage: "Invalid Stream URL"
+ },
+ 'settingsMap.streamType': {
+ optional: true,
+ errorMessage: "Invalid Stream Type",
+ matches: {
+ options: [/\b(?:webrtc|hls)\b/]
+ }
}
})
);
diff --git a/src/views/partial/channelSettings/settings.ejs b/src/views/partial/channelSettings/settings.ejs
index ec740eb..d8dd2ea 100644
--- a/src/views/partial/channelSettings/settings.ejs
+++ b/src/views/partial/channelSettings/settings.ejs
@@ -17,7 +17,11 @@ along with this program. If not, see