Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions config.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
21 changes: 19 additions & 2 deletions public/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand Down Expand Up @@ -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");
}
}
}

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down