mirror of https://github.com/calzoneman/sync.git
Merge changes from master
This commit is contained in:
parent
00abe7ced1
commit
565759decf
27
channel.js
27
channel.js
|
@ -27,6 +27,7 @@ var Filter = require("./filter.js").Filter;
|
|||
|
||||
var Channel = function(name) {
|
||||
Logger.syslog.log("Opening channel " + name);
|
||||
this.initialized = false;
|
||||
|
||||
this.name = name;
|
||||
// Initialize defaults
|
||||
|
@ -135,6 +136,8 @@ Channel.prototype.hasPermission = function(user, key) {
|
|||
Channel.prototype.loadDump = function() {
|
||||
fs.readFile("chandump/" + this.name, function(err, data) {
|
||||
if(err) {
|
||||
Logger.errlog.log("Failed to open channel dump " + this.name);
|
||||
Logger.errlog.log(err);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
@ -207,6 +210,7 @@ Channel.prototype.loadDump = function() {
|
|||
this.css = data.css || "";
|
||||
this.js = data.js || "";
|
||||
this.sendAll("channelCSSJS", {css: this.css, js: this.js});
|
||||
this.initialized = true;
|
||||
setTimeout(function() { incrementalDump(this); }.bind(this), 300000);
|
||||
}
|
||||
catch(e) {
|
||||
|
@ -217,6 +221,8 @@ Channel.prototype.loadDump = function() {
|
|||
}
|
||||
|
||||
Channel.prototype.saveDump = function() {
|
||||
if(!this.initialized)
|
||||
return;
|
||||
var filts = new Array(this.filters.length);
|
||||
for(var i = 0; i < this.filters.length; i++) {
|
||||
filts[i] = this.filters[i].pack();
|
||||
|
@ -309,10 +315,15 @@ Channel.prototype.saveRank = function(user) {
|
|||
}
|
||||
|
||||
Channel.prototype.getIPRank = function(ip) {
|
||||
var names = this.logins[ip] || [];
|
||||
if(names.length == 0) {
|
||||
var names = [];
|
||||
if(this.logins[ip] === undefined || this.logins[ip].length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
this.logins[ip].forEach(function(name) {
|
||||
names.push(name);
|
||||
});
|
||||
|
||||
var ranks = Database.getChannelRank(this.name, names);
|
||||
var rank = 0;
|
||||
for(var i = 0; i < ranks.length; i++) {
|
||||
|
@ -395,7 +406,7 @@ Channel.prototype.tryIPBan = function(actor, data) {
|
|||
if(!this.hasPermission(actor, "ban")) {
|
||||
return false;
|
||||
}
|
||||
if(typeof data.id != "string" || data.id.length != 15) {
|
||||
if(typeof data.id != "string") {
|
||||
return false;
|
||||
}
|
||||
if(typeof data.name != "string") {
|
||||
|
@ -628,16 +639,9 @@ Channel.prototype.kick = function(user, reason) {
|
|||
}
|
||||
|
||||
Channel.prototype.hideIP = function(ip) {
|
||||
while(ip.length < 15) {
|
||||
ip += "X";
|
||||
}
|
||||
var chars = new Array(15);
|
||||
for(var i = 0; i < ip.length; i++) {
|
||||
chars[i] = String.fromCharCode(ip.charCodeAt(i) ^ this.ipkey.charCodeAt(i));
|
||||
if(chars[i] == "X") {
|
||||
chars[i] = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return chars.join("");
|
||||
}
|
||||
|
@ -707,6 +711,9 @@ Channel.prototype.sendRankStuff = function(user) {
|
|||
this.sendACL(user);
|
||||
}
|
||||
|
||||
Channel.prototype.sendSeenLogins = function(user) {
|
||||
}
|
||||
|
||||
Channel.prototype.sendACL = function(user) {
|
||||
if(Rank.hasPermission(user, "acl")) {
|
||||
user.socket.emit("acl", Database.listChannelRanks(this.name));
|
||||
|
|
|
@ -180,5 +180,6 @@ exports.unload = function(chan) {
|
|||
if(chan.registered) {
|
||||
chan.saveDump();
|
||||
}
|
||||
exports.channels[chan.name] = null;
|
||||
delete exports.channels[chan.name];
|
||||
}
|
||||
|
|
5
user.js
5
user.js
|
@ -93,7 +93,7 @@ User.prototype.initCallbacks = function() {
|
|||
return;
|
||||
data.name = data.name.toLowerCase();
|
||||
// Channel already loaded
|
||||
if(data.name in Server.channels) {
|
||||
if(data.name in Server.channels && Server.channels[data.name] != null) {
|
||||
this.channel = Server.channels[data.name];
|
||||
}
|
||||
// Channel not loaded
|
||||
|
@ -391,7 +391,8 @@ User.prototype.initCallbacks = function() {
|
|||
if(this.noflood("requestSeenLogins", 0.25)) {
|
||||
return;
|
||||
}
|
||||
this.channel.sendRankStuff(this);
|
||||
// does nothing
|
||||
this.channel.sendSeenLogins(this);
|
||||
}
|
||||
}.bind(this));
|
||||
|
||||
|
|
Loading…
Reference in New Issue