Basic housekeeping, as well as very basic work on per-channel !toke commands
This commit is contained in:
parent
dc01b8a15a
commit
575244ac53
|
|
@ -334,6 +334,7 @@
|
|||
"SmoothAsEggs",
|
||||
"nosedive",
|
||||
"rip",
|
||||
"slorp"
|
||||
"slorp",
|
||||
"freeluigi"
|
||||
]
|
||||
}
|
||||
|
|
@ -19,8 +19,8 @@ const {validationResult, matchedData} = require('express-validator');
|
|||
|
||||
//local imports
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const accountUtils = require('../../../utils/sessionUtils');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
|
||||
//api account functions
|
||||
module.exports.post = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const accountUtils = require('../../../utils/sessionUtils');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
|
||||
|
||||
//api account functions
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//local imports
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const accountUtils = require('../../../utils/sessionUtils');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
|
||||
module.exports.get = async function(req, res){
|
||||
if(req.session.user){
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//local imports
|
||||
const permissionModel = require('../../../schemas/permissionSchema.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const permissionModel = require('../../../schemas/permissionSchema');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
|
||||
//api account functions
|
||||
module.exports.get = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ const {validationResult, matchedData} = require('express-validator');
|
|||
|
||||
//local imports
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const userBanModel = require('../../../schemas/userBanSchema.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const userBanModel = require('../../../schemas/userBanSchema');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ const {validationResult, matchedData} = require('express-validator');
|
|||
|
||||
//local imports
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const accountUtils = require('../../../utils/sessionUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const accountUtils = require('../../../utils/sessionUtils');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
const validResult = validationResult(req);
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
|
||||
//api list channel functions
|
||||
module.exports.get = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License
|
|||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
|
||||
//api list account functions
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const permissionModel = require('../../../schemas/permissionSchema.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const permissionModel = require('../../../schemas/permissionSchema');
|
||||
|
||||
//api permissions functions
|
||||
module.exports.get = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const tokeCommandModel = require('../../../schemas/tokebot/tokeCommandSchema.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const tokeCommandModel = require('../../../schemas/tokebot/tokeCommandSchema');
|
||||
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const {userModel} = require('../../../schemas/userSchema.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
const permissionModel = require('../../../schemas/permissionSchema.js')
|
||||
const permissionModel = require('../../../schemas/permissionSchema')
|
||||
|
||||
//api account functions
|
||||
module.exports.get = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
|
||||
//api account functions
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
|
||||
//local imports
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
|
||||
//api account functions
|
||||
module.exports.get = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -18,9 +18,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema.js');
|
||||
const permissionModel = require('../../../schemas/permissionSchema.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
const permissionModel = require('../../../schemas/permissionSchema');
|
||||
|
||||
//api account functions
|
||||
module.exports.get = async function(req, res){
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const {userModel} = require('../../../schemas/userSchema.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const {userModel} = require('../../../schemas/userSchema');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
|
||||
//api account functions
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
|
||||
//api account functions
|
||||
|
|
|
|||
94
src/controllers/api/channel/tokeCommandController.js
Normal file
94
src/controllers/api/channel/tokeCommandController.js
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/*Canopy - The next generation of stoner streaming software
|
||||
Copyright (C) 2024 Rainbownapkin and the TTN Community
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||
|
||||
//npm imports
|
||||
const {validationResult, matchedData} = require('express-validator');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../../../utils/loggerUtils');
|
||||
const channelModel = require('../../../schemas/channel/channelSchema');
|
||||
|
||||
module.exports.get = async function(req, res){
|
||||
try{
|
||||
const tokeList = await tokeCommandModel.getCommandStrings();
|
||||
|
||||
res.status(200);
|
||||
return res.send(tokeList);
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.post = async function(req, res){
|
||||
try{
|
||||
//get validation error results
|
||||
const validResult = validationResult(req);
|
||||
|
||||
//if they're empty
|
||||
if(validResult.isEmpty()){
|
||||
/*
|
||||
const {command} = matchedData(req);
|
||||
const tokeDB = await tokeCommandModel.findOne({command});
|
||||
|
||||
if(tokeDB != null){
|
||||
return errorHandler(res, `Toke command '!${command}' already exists!`);
|
||||
}
|
||||
|
||||
//Add the toke
|
||||
await tokeCommandModel.create({command});
|
||||
|
||||
//Return the updated command list
|
||||
res.status(200);
|
||||
return res.send(await tokeCommandModel.getCommandStrings());*/
|
||||
}else{
|
||||
//otherwise scream
|
||||
res.status(400);
|
||||
return res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.delete = async function(req, res){
|
||||
try{
|
||||
//get validation error results
|
||||
const validResult = validationResult(req);
|
||||
|
||||
//if they're empty
|
||||
if(validResult.isEmpty()){
|
||||
/*
|
||||
const {command} = matchedData(req);
|
||||
const tokeDB = await tokeCommandModel.findOne({command});
|
||||
|
||||
if(tokeDB == null){
|
||||
return errorHandler(res, `Cannot delete non-existant toke command '!${command}'!`);
|
||||
}
|
||||
|
||||
await tokeDB.deleteOne();
|
||||
|
||||
//Return the updated command list
|
||||
res.status(200);
|
||||
return res.send(await tokeCommandModel.getCommandStrings());*/
|
||||
}else{
|
||||
//otherwise scream
|
||||
res.status(400);
|
||||
return res.send({errors: validResult.array()})
|
||||
}
|
||||
}catch(err){
|
||||
return exceptionHandler(res, err);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,7 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
const config = require('../../config.json');
|
||||
|
||||
//local imports
|
||||
const {exceptionHandler, errorHandler} = require('../utils/loggerUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../utils/loggerUtils');
|
||||
const channelModel = require('../schemas/channel/channelSchema');
|
||||
|
||||
//root index functions
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
|||
|
||||
//Local Imports
|
||||
const {userModel} = require('../schemas/userSchema');
|
||||
const {exceptionHandler, errorHandler} = require('../utils/loggerUtils.js');
|
||||
const {exceptionHandler, errorHandler} = require('../utils/loggerUtils');
|
||||
|
||||
//Config
|
||||
const config = require('../../config.json');
|
||||
|
|
|
|||
|
|
@ -72,7 +72,11 @@ const channelSchema = new mongoose.Schema({
|
|||
enum: permissionModel.rankEnum
|
||||
}
|
||||
}],
|
||||
//Thankfully we don't have to keep track of alts, ips, or deleted users so this should be a little easier :P
|
||||
tokeCommands: [{
|
||||
type: mongoose.SchemaTypes.String,
|
||||
required: true
|
||||
}],
|
||||
//Thankfully we don't have to keep track of alts, ips, or deleted users so this should be a lot easier than site-wide bans :P
|
||||
banList: [channelBanSchema]
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -228,7 +228,12 @@ class canopyUXUtils{
|
|||
}
|
||||
|
||||
calcWidth(px){
|
||||
return (px / window.innerWidth) * 100;
|
||||
//I cannot fucking believe they added a clamp function to CSS before JS...
|
||||
const width = (px / window.innerWidth) * 100;
|
||||
|
||||
//Little hacky but this ensures that if our click dragger tries to do something that it should absolutely never be doing
|
||||
//it'll be told to sit down, shut up, and fuck off.
|
||||
return width < 100 ? width : 20;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue