Trying to improve cpu on server..

This commit is contained in:
Kasper Rynning-Tønnesen
2017-09-18 12:30:16 +02:00
parent 71f5be88df
commit 440d5dc677
14 changed files with 2451 additions and 647 deletions

View File

@@ -3,9 +3,9 @@ var thumbnail = function(msg, coll, guid, offline, socket) {
msg.thumbnail = msg.thumbnail.replace(/^https?\:\/\//i, "");
if(msg.thumbnail.substring(0,2) != "//") msg.thumbnail = "//" + msg.thumbnail;
var channel = msg.channel.toLowerCase();
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
var hash = hash_pass(decrypt_string(socket.zoff_id, msg.adminpass));
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == decrypt_string(socketid, msg.pass)))) {
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
db.collection("suggested_thumbnails").update({channel: channel}, {$set:{thumbnail: msg.thumbnail}}, {upsert:true}, function(err, docs){
socket.emit("toast", "suggested_thumbnail");
@@ -23,9 +23,9 @@ var thumbnail = function(msg, coll, guid, offline, socket) {
var description = function(msg, coll, guid, offline, socket) {
if(msg.description && msg.channel && msg.adminpass && msg.description.length < 100){
var channel = msg.channel.toLowerCase();
var hash = Functions.hash_pass(Functions.decrypt_string(socket.zoff_id, msg.adminpass));
var hash = hash_pass(decrypt_string(socket.zoff_id, msg.adminpass));
db.collection(channel).find({views:{$exists:true}}, function(err, docs){
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == Functions.decrypt_string(socketid, msg.pass)))) {
if(docs.length > 0 && (docs[0].userpass == undefined || docs[0].userpass == "" || (msg.hasOwnProperty('pass') && docs[0].userpass == decrypt_string(socketid, msg.pass)))) {
if(docs !== null && docs.length !== 0 && docs[0].adminpass !== "" && docs[0].adminpass == hash){
db.collection("suggested_descriptions").update({channel: channel}, {$set:{description: msg.description}}, {upsert:true}, function(err, docs){
socket.emit("toast", "suggested_description");
@@ -39,6 +39,3 @@ var description = function(msg, coll, guid, offline, socket) {
socket.emit("toast", "description_denied");
}
}
module.exports.description = description;
module.exports.thumbnail = thumbnail;