Make it impossible to ever lose rank when logging in
This commit is contained in:
parent
2e77cb4499
commit
95c2118740
|
@ -1,3 +1,10 @@
|
|||
Mon Oct 14 18:13 2013 CDT
|
||||
* lib/channel.js, lib/database.js: Add a separate database query
|
||||
for saving ranks on login (insert only, do nothing if the name
|
||||
exists). Should make it actually impossible to ever lose rank
|
||||
when logging in (I thought it was impossible before but someone
|
||||
claimed it happened).
|
||||
|
||||
Mon Oct 14 16:37 2013 CDT
|
||||
* lib/bgtask.js: Add an interval for dumping all loaded channels
|
||||
* lib/channel.js: Remove per-channel dump interval
|
||||
|
|
|
@ -499,6 +499,12 @@ Channel.prototype.saveRank = function (user, callback) {
|
|||
this.server.db.setChannelRank(this.name, user.name, user.rank, callback);
|
||||
}
|
||||
|
||||
Channel.prototype.saveInitialRank = function (user, callback) {
|
||||
if(!this.registered)
|
||||
return;
|
||||
this.server.db.insertChannelRank(this.name, user.name, user.rank, callback);
|
||||
};
|
||||
|
||||
Channel.prototype.getIPRank = function (ip, callback) {
|
||||
var self = this;
|
||||
self.server.db.listAliases(ip, function (err, names) {
|
||||
|
@ -1100,7 +1106,7 @@ Channel.prototype.broadcastNewUser = function(user) {
|
|||
});
|
||||
|
||||
if(user.rank > 0) {
|
||||
self.saveRank(user);
|
||||
self.saveInitialRank(user);
|
||||
}
|
||||
|
||||
var msg = user.name + " joined (aliases: ";
|
||||
|
|
|
@ -557,6 +557,23 @@ Database.prototype.setChannelRank = function (channame, name, rank, callback) {
|
|||
self.query(query, [name, rank, rank], callback);
|
||||
};
|
||||
|
||||
Database.prototype.insertChannelRank = function (channame, name, rank, callback) {
|
||||
var self = this;
|
||||
if(typeof callback !== "function")
|
||||
callback = blackHole;
|
||||
|
||||
if(!$util.isValidChannelName(channame)) {
|
||||
callback("Invalid channel name", null);
|
||||
return;
|
||||
}
|
||||
|
||||
var query = "INSERT INTO `chan_" + channame + "_ranks` " +
|
||||
"(name, rank) VALUES (?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE rank=rank";
|
||||
|
||||
self.query(query, [name, rank], callback);
|
||||
};
|
||||
|
||||
Database.prototype.listChannelRanks = function (channame, callback) {
|
||||
var self = this;
|
||||
if(typeof callback !== "function")
|
||||
|
|
Loading…
Reference in a new issue