diff --git a/.gitignore b/.gitignore index a4c57d4..414d20c 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ build/Release # Dependency directory # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git node_modules + +# Webstorm project files +.idea \ No newline at end of file diff --git a/config.template.js b/config.template.js index 76f6d8f..881df33 100644 --- a/config.template.js +++ b/config.template.js @@ -29,5 +29,7 @@ Config.privateMessaging = true; //Connect 4 URL: If you would prefer to host it yourself, https://github.com/tannerkrewson/connect4lansite Config.connectFourUrl = 'https://kevinshannon.dev/connect4/'; +//Automatically accept all posts +Config.allowAllPosts = false; module.exports = Config; diff --git a/public/js/client.js b/public/js/client.js index 3122fdf..7faad2c 100644 --- a/public/js/client.js +++ b/public/js/client.js @@ -13,6 +13,7 @@ var socket = io(); // if the user is OP. this flag is just for cosmetics, which won't // do anything if the user isn't OP, because the server won't allow it. var isThisUserOP = false; +var allPostsAreAllowed= false; //will contain all the loaded client boxes var BoxNames = []; @@ -282,13 +283,18 @@ SendToServer.areWeOP = function(){ SendToServer.generic('areWeOP', {}); } +SendToServer.areAllPostsAllowed = function(){ + SendToServer.generic('areAllPostsAllowed', {}); +} function Popup() {} Popup.requestSent = function() { - //don't annoy the admins with constant popups + //don't show popup when user is admin or all posts are allowed if (!isThisUserOP) { - swal("Request sent!", "Now, wait for the admin to respond.", "success"); + if(!allPostsAreAllowed) { + swal("Request sent!", "Now, wait for the admin to respond.", "success"); + } } } @@ -345,6 +351,8 @@ socket.on('newStream', function(msg) { //see if we are op SendToServer.areWeOP(); + SendToServer.areAllPostsAllowed(); + //deletes all boxes currently in the array mainStream.clearArray(); @@ -390,6 +398,15 @@ socket.on('areWeOP', function(msg) { } }); +socket.on('areAllPostsAllowed', function(msg) { + allowCheck = msg && true; + //if we're not already OP + + if (!allPostsAreAllowed && allowCheck){ + allPostsAreAllowed = true; + } +}); + //shows a popup to inform the user if there request was accepted or denied socket.on('requestAccepted', function(msg) { Popup.requestAccepted(msg); diff --git a/server.js b/server.js index 07c9a79..aa2bcf2 100644 --- a/server.js +++ b/server.js @@ -762,8 +762,8 @@ function RequestManager() { } RequestManager.prototype.addRequest = function(userThatMadeRequest, requestString, acceptFunction, denyFunction){ - //if the user is op, accept the request, no questions asked - if (userThatMadeRequest.isOp) { + //if the user is op or the config is set to allow all posts, accept the request, no questions asked + if (userThatMadeRequest.isOp||Config.allowAllPosts) { //I bypass adding the request and using the handler here // the true tells the function to supress the usual popup // that users receive when their popup is accepted @@ -971,6 +971,10 @@ io.on('connection', function(socket) { } }); + socket.on('areAllPostsAllowed', function(msg) { + socket.emit('areAllPostsAllowed', Config.allowAllPosts); + }); + socket.on('disconnect', function() { //console.log('Unauthenticated user disconnected'); //mainStream.users.removeUser(user);