Compare commits
No commits in common. "e88ef298529022991c46e5e0ab2d6b4801ae24d2" and "1e48d3af2c6dad405a00094d26bb70021b3b899d" have entirely different histories.
e88ef29852
...
1e48d3af2c
|
|
@ -1,79 +0,0 @@
|
||||||
/*Canopy - The next generation of stoner streaming software
|
|
||||||
Copyright (C) 2024-2025 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/>.*/
|
|
||||||
|
|
||||||
//local includes
|
|
||||||
const loggerUtils = require("../utils/loggerUtils");
|
|
||||||
const socketUtils = require("../utils/socketUtils");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class containg global server-side logic for handling namespaces outside of the main one
|
|
||||||
*/
|
|
||||||
class auxServer{
|
|
||||||
/**
|
|
||||||
* Instantiates object containing global server-side private message relay logic
|
|
||||||
* @param {Socket.io} io - Socket.io server instanced passed down from server.js
|
|
||||||
* @param {channelManager} chanServer - Sister channel management server object
|
|
||||||
*/
|
|
||||||
constructor(io, chanServer, namespace){
|
|
||||||
/**
|
|
||||||
* Socket.io server instance passed down from server.js
|
|
||||||
*/
|
|
||||||
this.io = io;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sister channel management server object
|
|
||||||
*/
|
|
||||||
this.chanServer = chanServer;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Socket.io server namespace for handling messaging
|
|
||||||
*/
|
|
||||||
this.namespace = io.of(namespace);
|
|
||||||
|
|
||||||
//Handle connections from private messaging namespace
|
|
||||||
this.namespace.on("connection", this.handleConnection.bind(this) );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles global server-side initialization for new connections to aux server
|
|
||||||
* @param {Socket} socket - Requesting Socket
|
|
||||||
*/
|
|
||||||
async handleConnection(socket){
|
|
||||||
try{
|
|
||||||
//ensure unbanned ip and valid CSRF token
|
|
||||||
if(!(await socketUtils.validateSocket(socket))){
|
|
||||||
socket.disconnect();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//If the socket wasn't authorized
|
|
||||||
if(await socketUtils.authSocketLite(socket) == null){
|
|
||||||
socket.disconnect();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}catch(err){
|
|
||||||
//Flip a table if something fucks up
|
|
||||||
return loggerUtils.socketCriticalExceptionHandler(socket, err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
defineListeners(socket){
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = auxServer;
|
|
||||||
|
|
@ -14,25 +14,44 @@ GNU Affero General Public License for more details.
|
||||||
You should have received a copy of the GNU Affero General Public License
|
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/>.*/
|
along with this program. If not, see <https://www.gnu.org/licenses/>.*/
|
||||||
|
|
||||||
|
//NPM Imports
|
||||||
|
const validator = require('validator');//No express here, so regular validator it is!
|
||||||
|
|
||||||
//local includes
|
//local includes
|
||||||
const auxServer = require('../auxServer');
|
|
||||||
const chatPreprocessor = require('../chatPreprocessor');
|
const chatPreprocessor = require('../chatPreprocessor');
|
||||||
const loggerUtils = require("../../utils/loggerUtils");
|
const loggerUtils = require("../../utils/loggerUtils");
|
||||||
|
const socketUtils = require("../../utils/socketUtils");
|
||||||
const message = require("./message");
|
const message = require("./message");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class containg global server-side private message relay logic
|
* Class containg global server-side private message relay logic
|
||||||
*/
|
*/
|
||||||
class pmHandler extends auxServer{
|
class pmHandler{
|
||||||
/**
|
/**
|
||||||
* Instantiates object containing global server-side private message relay logic
|
* Instantiates object containing global server-side private message relay logic
|
||||||
* @param {Socket.io} io - Socket.io server instanced passed down from server.js
|
* @param {Socket.io} io - Socket.io server instanced passed down from server.js
|
||||||
* @param {channelManager} chanServer - Sister channel management server object
|
* @param {channelManager} chanServer - Sister channel management server object
|
||||||
*/
|
*/
|
||||||
constructor(io, chanServer){
|
constructor(io, chanServer){
|
||||||
super(io, chanServer, "/pm");
|
/**
|
||||||
|
* Socket.io server instance passed down from server.js
|
||||||
|
*/
|
||||||
|
this.io = io;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sister channel management server object
|
||||||
|
*/
|
||||||
|
this.chanServer = chanServer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Socket.io server namespace for handling messaging
|
||||||
|
*/
|
||||||
|
this.namespace = io.of('/pm');
|
||||||
|
|
||||||
this.chatPreprocessor = new chatPreprocessor(null, null);
|
this.chatPreprocessor = new chatPreprocessor(null, null);
|
||||||
|
|
||||||
|
//Handle connections from private messaging namespace
|
||||||
|
this.namespace.on("connection", this.handleConnection.bind(this) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,21 +59,31 @@ class pmHandler extends auxServer{
|
||||||
* @param {Socket} socket - Requesting Socket
|
* @param {Socket} socket - Requesting Socket
|
||||||
*/
|
*/
|
||||||
async handleConnection(socket){
|
async handleConnection(socket){
|
||||||
//Check if we're properly authorized
|
try{
|
||||||
const authorized = await super.handleConnection(socket, "${user}");
|
//ensure unbanned ip and valid CSRF token
|
||||||
|
if(!(await socketUtils.validateSocket(socket))){
|
||||||
|
socket.disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//If we're authorized
|
//If the socket wasn't authorized
|
||||||
if(authorized){
|
if(await socketUtils.authSocketLite(socket) == null){
|
||||||
//Throw the user into their own unique channel
|
socket.disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Throw socket into room named after it's user
|
||||||
socket.join(socket.user.user);
|
socket.join(socket.user.user);
|
||||||
|
|
||||||
//Define listeners
|
//Define network related event listeners against socket
|
||||||
this.defineListeners(socket);
|
this.defineListeners(socket);
|
||||||
|
}catch(err){
|
||||||
|
//Flip a table if something fucks up
|
||||||
|
return loggerUtils.socketCriticalExceptionHandler(socket, err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defineListeners(socket){
|
defineListeners(socket){
|
||||||
super.defineListeners(socket);
|
|
||||||
socket.on("pm", (data)=>{this.handlePM(data, socket)});
|
socket.on("pm", (data)=>{this.handlePM(data, socket)});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,7 @@ class pmPanel extends panelObj{
|
||||||
handleAutoScroll(){
|
handleAutoScroll(){
|
||||||
//If autoscroll is enabled
|
//If autoscroll is enabled
|
||||||
if(this.autoScroll){
|
if(this.autoScroll){
|
||||||
|
console.log("SCROLLME");
|
||||||
//Set seshBuffer scrollTop to the difference between scrollHeight and buffer height (scroll to the bottom)
|
//Set seshBuffer scrollTop to the difference between scrollHeight and buffer height (scroll to the bottom)
|
||||||
this.seshBuffer.scrollTop = this.seshBuffer.scrollHeight - Math.round(this.seshBuffer.getBoundingClientRect().height);
|
this.seshBuffer.scrollTop = this.seshBuffer.scrollHeight - Math.round(this.seshBuffer.getBoundingClientRect().height);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue