diff --git a/src/app/channel/chatHandler.js b/src/app/channel/chatHandler.js
index e326e02..e8a6804 100644
--- a/src/app/channel/chatHandler.js
+++ b/src/app/channel/chatHandler.js
@@ -84,6 +84,11 @@ module.exports = class{
this.server.io.in(socket.chan).emit("chatMessage", {user: user.user, flair: user.flair, highLevel: user.highLevel, msg, type});
}
+ relayServerAnnouncement(msg){
+ //This codebase is always at a 10
+ this.server.io.emit("chatMessage", {user: "Server", flair: "", highLevel: 10, msg, type: "announcement"});
+ }
+
relayChannelAnnouncement(socket, msg){
//This codebase is always at a 10
this.server.io.in(socket.chan).emit("chatMessage", {user: "Channel", flair: "", highLevel: 10, msg, type: "announcement"});
diff --git a/src/app/channel/commandPreprocessor.js b/src/app/channel/commandPreprocessor.js
index ddb1721..805cbf1 100644
--- a/src/app/channel/commandPreprocessor.js
+++ b/src/app/channel/commandPreprocessor.js
@@ -18,6 +18,7 @@ along with this program. If not, see .*/
const validator = require('validator');//No express here, so regular validator it is!
//Local Imports
+const permissionModel = require('../../schemas/permissionSchema');
const channelModel = require('../../schemas/channel/channelSchema');
module.exports = class commandPreprocessor{
@@ -112,4 +113,14 @@ class commandProcessor{
this.server.chatHandler.relayChannelAnnouncement(this.preprocessor.socket, this.preprocessor.commandArray.join(''));
}
}
+
+ async serverannounce(){
+ //Check if the user has permission, and publicly shame them if they don't (lmao)
+ if(!(this.preprocessor.sendFlag = !(await permissionModel.permCheck(this.preprocessor.socket.user, 'announce')))){
+ //splice out our whisper
+ this.preprocessor.commandArray.splice(0,2);
+ //send it
+ this.server.chatHandler.relayServerAnnouncement(this.preprocessor.commandArray.join(''));
+ }
+ }
}
\ No newline at end of file
diff --git a/src/schemas/permissionSchema.js b/src/schemas/permissionSchema.js
index f5e59c7..8f361bd 100644
--- a/src/schemas/permissionSchema.js
+++ b/src/schemas/permissionSchema.js
@@ -18,6 +18,8 @@ along with this program. If not, see .*/
const {mongoose} = require('mongoose');
//Local Imports
+//const {userModel} = require('./userSchema');
+const userSchema = require('./userSchema');
const channelPermissionSchema = require('./channel/channelPermissionSchema');
//This originally belonged to the permissionSchema, but this avoids circular dependencies.
@@ -43,6 +45,12 @@ const permissionSchema = new mongoose.Schema({
default: "admin",
required: true
},
+ announce: {
+ type: mongoose.SchemaTypes.String,
+ enum: rankEnum,
+ default: "admin",
+ required: true
+ },
banUser: {
type: mongoose.SchemaTypes.String,
enum: rankEnum,
@@ -105,6 +113,11 @@ permissionSchema.statics.rankToNum = function(rank){
}
permissionSchema.statics.permCheck = async function(user, perm){
+ const userDB = await userSchema.userModel.findOne({user: user.user});
+ return await this.permCheckByUserDoc(userDB, perm);
+}
+
+permissionSchema.statics.permCheckByUserDoc = async function(user, perm){
//Get permission list
const perms = await this.getPerms();
diff --git a/src/validators/permissionsValidator.js b/src/validators/permissionsValidator.js
index d07eec8..061aaa6 100644
--- a/src/validators/permissionsValidator.js
+++ b/src/validators/permissionsValidator.js
@@ -46,6 +46,12 @@ module.exports.permissionsValidator = {
options: module.exports.isRank
},
},
+ 'permissionsMap.announce': {
+ optional: true,
+ custom: {
+ options: module.exports.isRank
+ },
+ },
'permissionsMap.banUser': {
optional: true,
custom: {