From 6ac64a6cf30216113cc5352d48938da90485efdf Mon Sep 17 00:00:00 2001 From: calzoneman Date: Thu, 26 Dec 2013 10:17:33 -0500 Subject: [PATCH] Fix a few things --- lib/actionlog.js | 12 +++++++----- lib/channel.js | 4 ++-- lib/database/channels.js | 15 ++++++++------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/actionlog.js b/lib/actionlog.js index 3f0e52b2..f033df89 100644 --- a/lib/actionlog.js +++ b/lib/actionlog.js @@ -25,21 +25,22 @@ module.exports = { } } - db.recordAction(ip, name, action, args); + //db.recordAction(ip, name, action, args); }, clear: function (actions) { var db = Server.getServer().db; - db.clearActions(actions); + //db.clearActions(actions); }, clearOne: function (item) { var db = Server.getServer().db; - db.clearSingleAction(item); + //db.clearSingleAction(item); }, throttleRegistrations: function (ip, callback) { var db = Server.getServer().db; + /* db.recentRegistrationCount(ip, function (err, count) { if(err) { callback(err, null); @@ -48,15 +49,16 @@ module.exports = { callback(null, count > 4); }); + */ }, listActionTypes: function (callback) { var db = Server.getServer().db; - db.listActionTypes(callback); + //db.listActionTypes(callback); }, listActions: function (types, callback) { var db = Server.getServer().db; - db.listActions(types, callback); + //db.listActions(types, callback); } }; diff --git a/lib/channel.js b/lib/channel.js index 7c1e4f01..19ffc145 100644 --- a/lib/channel.js +++ b/lib/channel.js @@ -136,9 +136,9 @@ var Channel = function(name) { } db.channels.load(self, function (err) { - if (err) + if (err && err !== "Channel is not registered") return; - else if (!err || err === "Channel is not registered") + else self.dbloaded = true; self.tryLoadDump(); diff --git a/lib/database/channels.js b/lib/database/channels.js index 840ed72a..691b902c 100644 --- a/lib/database/channels.js +++ b/lib/database/channels.js @@ -36,10 +36,11 @@ function createBansTable(name, callback) { } function initTables(name, owner, callback) { - if (!valid(chan)) { + if (!valid(name)) { callback("Invalid channel name", null); return; } + createRanksTable(name, function (err) { if (err) { callback(err, null); @@ -91,12 +92,12 @@ module.exports = { return; } - if (!valid(chan)) { + if (!valid(name)) { callback("Invalid channel name", null); return; } - dbutil.query("SELECT name FROM `channels` WHERE name=?", + db.query("SELECT name FROM `channels` WHERE name=?", [name], function (err, rows) { if (err) { @@ -120,7 +121,7 @@ module.exports = { return; } - dbutil.query("SELECT * FROM `channels` WHERE name=?", + db.query("SELECT * FROM `channels` WHERE name=?", [name], function (err, rows) { if (err) { @@ -139,7 +140,7 @@ module.exports = { return; } - dbutil.query("SELECT * FROM `channels` WHERE name LIKE ?", + db.query("SELECT * FROM `channels` WHERE name LIKE ?", ["%" + name + "%"], function (err, rows) { if (err) { @@ -180,7 +181,7 @@ module.exports = { return; } - dbutil.query("INSERT INTO `channels` " + + db.query("INSERT INTO `channels` " + "(`name`, `owner`, `time`) VALUES (?, ?, ?)", [name, owner, Date.now()], function (err, res) { @@ -191,7 +192,7 @@ module.exports = { initTables(name, owner, function (err, res) { if (err) { - dbutil.query("DELETE FROM `channels` WHERE name=?", [name]); + db.query("DELETE FROM `channels` WHERE name=?", [name]); callback(err, null); return; }