Fix a few things

This commit is contained in:
calzoneman 2013-12-26 10:17:33 -05:00
parent 423c787ccb
commit 6ac64a6cf3
3 changed files with 17 additions and 14 deletions

View File

@ -25,21 +25,22 @@ module.exports = {
} }
} }
db.recordAction(ip, name, action, args); //db.recordAction(ip, name, action, args);
}, },
clear: function (actions) { clear: function (actions) {
var db = Server.getServer().db; var db = Server.getServer().db;
db.clearActions(actions); //db.clearActions(actions);
}, },
clearOne: function (item) { clearOne: function (item) {
var db = Server.getServer().db; var db = Server.getServer().db;
db.clearSingleAction(item); //db.clearSingleAction(item);
}, },
throttleRegistrations: function (ip, callback) { throttleRegistrations: function (ip, callback) {
var db = Server.getServer().db; var db = Server.getServer().db;
/*
db.recentRegistrationCount(ip, function (err, count) { db.recentRegistrationCount(ip, function (err, count) {
if(err) { if(err) {
callback(err, null); callback(err, null);
@ -48,15 +49,16 @@ module.exports = {
callback(null, count > 4); callback(null, count > 4);
}); });
*/
}, },
listActionTypes: function (callback) { listActionTypes: function (callback) {
var db = Server.getServer().db; var db = Server.getServer().db;
db.listActionTypes(callback); //db.listActionTypes(callback);
}, },
listActions: function (types, callback) { listActions: function (types, callback) {
var db = Server.getServer().db; var db = Server.getServer().db;
db.listActions(types, callback); //db.listActions(types, callback);
} }
}; };

View File

@ -136,9 +136,9 @@ var Channel = function(name) {
} }
db.channels.load(self, function (err) { db.channels.load(self, function (err) {
if (err) if (err && err !== "Channel is not registered")
return; return;
else if (!err || err === "Channel is not registered") else
self.dbloaded = true; self.dbloaded = true;
self.tryLoadDump(); self.tryLoadDump();

View File

@ -36,10 +36,11 @@ function createBansTable(name, callback) {
} }
function initTables(name, owner, callback) { function initTables(name, owner, callback) {
if (!valid(chan)) { if (!valid(name)) {
callback("Invalid channel name", null); callback("Invalid channel name", null);
return; return;
} }
createRanksTable(name, function (err) { createRanksTable(name, function (err) {
if (err) { if (err) {
callback(err, null); callback(err, null);
@ -91,12 +92,12 @@ module.exports = {
return; return;
} }
if (!valid(chan)) { if (!valid(name)) {
callback("Invalid channel name", null); callback("Invalid channel name", null);
return; return;
} }
dbutil.query("SELECT name FROM `channels` WHERE name=?", db.query("SELECT name FROM `channels` WHERE name=?",
[name], [name],
function (err, rows) { function (err, rows) {
if (err) { if (err) {
@ -120,7 +121,7 @@ module.exports = {
return; return;
} }
dbutil.query("SELECT * FROM `channels` WHERE name=?", db.query("SELECT * FROM `channels` WHERE name=?",
[name], [name],
function (err, rows) { function (err, rows) {
if (err) { if (err) {
@ -139,7 +140,7 @@ module.exports = {
return; return;
} }
dbutil.query("SELECT * FROM `channels` WHERE name LIKE ?", db.query("SELECT * FROM `channels` WHERE name LIKE ?",
["%" + name + "%"], ["%" + name + "%"],
function (err, rows) { function (err, rows) {
if (err) { if (err) {
@ -180,7 +181,7 @@ module.exports = {
return; return;
} }
dbutil.query("INSERT INTO `channels` " + db.query("INSERT INTO `channels` " +
"(`name`, `owner`, `time`) VALUES (?, ?, ?)", "(`name`, `owner`, `time`) VALUES (?, ?, ?)",
[name, owner, Date.now()], [name, owner, Date.now()],
function (err, res) { function (err, res) {
@ -191,7 +192,7 @@ module.exports = {
initTables(name, owner, function (err, res) { initTables(name, owner, function (err, res) {
if (err) { if (err) {
dbutil.query("DELETE FROM `channels` WHERE name=?", [name]); db.query("DELETE FROM `channels` WHERE name=?", [name]);
callback(err, null); callback(err, null);
return; return;
} }