Bugfix for moderators

This commit is contained in:
calzoneman 2013-04-04 15:41:41 -05:00
parent 0e49f06fbf
commit 66dde5f337
3 changed files with 7 additions and 5 deletions

View file

@ -172,11 +172,11 @@ Channel.prototype.tryRegister = function(user) {
}
}
Channel.prototype.getRank = function(user) {
Channel.prototype.getRank = function(name) {
if(!this.registered) {
return Rank.Guest;
}
return Database.lookupChannelRank(this.name, user.name);
return Database.lookupChannelRank(this.name, name);
}
Channel.prototype.saveRank = function(user) {

View file

@ -180,9 +180,11 @@ exports.lookupChannelRank = function(channame, username) {
var query = "SELECT * FROM chan_{1}_ranks WHERE name='{2}'"
.replace("{1}", channame)
.replace("{2}", username);
console.log(query);
var results = db.querySync(query);
if(!results)
if(!results) {
return Rank.Guest;
}
var rows = results.fetchAllSync();
if(rows.length == 0) {
return Rank.Guest;

View file

@ -84,13 +84,13 @@ User.prototype.initCallbacks = function() {
this.socket.on("promote", function(data) {
if(this.channel != null) {
this.channel.tryPromote(this, data);
this.channel.tryPromoteUser(this, data);
}
}.bind(this));
this.socket.on("demote", function(data) {
if(this.channel != null) {
this.channel.tryDemote(this, data);
this.channel.tryDemoteUser(this, data);
}
}.bind(this));