Fix a few things
This commit is contained in:
parent
1cbb1c2a6a
commit
573e59680e
|
|
@ -547,7 +547,7 @@ Channel.prototype.join = function (user) {
|
||||||
self.sendVoteskipUpdate(self.users);
|
self.sendVoteskipUpdate(self.users);
|
||||||
self.sendUsercount(self.users);
|
self.sendUsercount(self.users);
|
||||||
|
|
||||||
user.whenLoggedIn(function () {
|
user.once("channelRank", function () {
|
||||||
if (!self.registered) {
|
if (!self.registered) {
|
||||||
afterLogin();
|
afterLogin();
|
||||||
return;
|
return;
|
||||||
|
|
@ -1341,7 +1341,7 @@ Channel.prototype.sendPoll = function (users) {
|
||||||
var unobscured = self.poll.packUpdate(true);
|
var unobscured = self.poll.packUpdate(true);
|
||||||
|
|
||||||
users.forEach(function (u) {
|
users.forEach(function (u) {
|
||||||
if (self.hasPermission(u, "viewpollresults")) {
|
if (self.hasPermission(u, "viewhiddenpoll")) {
|
||||||
u.socket.emit("newPoll", unobscured);
|
u.socket.emit("newPoll", unobscured);
|
||||||
} else {
|
} else {
|
||||||
u.socket.emit("newPoll", obscured);
|
u.socket.emit("newPoll", obscured);
|
||||||
|
|
|
||||||
103
lib/utilities.js
103
lib/utilities.js
|
|
@ -1,49 +1,57 @@
|
||||||
var crypto = require("crypto");
|
(function () {
|
||||||
|
var root, crypto = false;
|
||||||
|
|
||||||
/*
|
if (typeof window === "undefined") {
|
||||||
Set prototype- simple wrapper around JS objects to
|
root = module.exports;
|
||||||
manipulate them like a set
|
} else {
|
||||||
*/
|
root = window.utils = {};
|
||||||
var Set = function (items) {
|
|
||||||
this._items = {};
|
|
||||||
var self = this;
|
|
||||||
if (items instanceof Array)
|
|
||||||
items.forEach(function (it) { self.add(it); });
|
|
||||||
};
|
|
||||||
|
|
||||||
Set.prototype.contains = function (what) {
|
|
||||||
return (what in this._items);
|
|
||||||
};
|
|
||||||
|
|
||||||
Set.prototype.add = function (what) {
|
|
||||||
this._items[what] = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
Set.prototype.remove = function (what) {
|
|
||||||
if (what in this._items)
|
|
||||||
delete this._items[what];
|
|
||||||
};
|
|
||||||
|
|
||||||
Set.prototype.clear = function () {
|
|
||||||
this._items = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
Set.prototype.forEach = function (fn) {
|
|
||||||
for (var k in this._items) {
|
|
||||||
fn(k);
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
module.exports = {
|
if (typeof require === "function") {
|
||||||
isValidChannelName: function (name) {
|
crypto = require("crypto");
|
||||||
|
}
|
||||||
|
|
||||||
|
var Set = function (items) {
|
||||||
|
this._items = {};
|
||||||
|
var self = this;
|
||||||
|
if (items instanceof Array)
|
||||||
|
items.forEach(function (it) { self.add(it); });
|
||||||
|
};
|
||||||
|
|
||||||
|
Set.prototype.contains = function (what) {
|
||||||
|
return (what in this._items);
|
||||||
|
};
|
||||||
|
|
||||||
|
Set.prototype.add = function (what) {
|
||||||
|
this._items[what] = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
Set.prototype.remove = function (what) {
|
||||||
|
if (what in this._items)
|
||||||
|
delete this._items[what];
|
||||||
|
};
|
||||||
|
|
||||||
|
Set.prototype.clear = function () {
|
||||||
|
this._items = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
Set.prototype.forEach = function (fn) {
|
||||||
|
for (var k in this._items) {
|
||||||
|
fn(k);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
root.Set = Set;
|
||||||
|
|
||||||
|
root.isValidChannelName = function (name) {
|
||||||
return name.match(/^[\w-]{1,30}$/);
|
return name.match(/^[\w-]{1,30}$/);
|
||||||
},
|
},
|
||||||
|
|
||||||
isValidUserName: function (name) {
|
root.isValidUserName = function (name) {
|
||||||
return name.match(/^[\w-]{1,20}$/);
|
return name.match(/^[\w-]{1,20}$/);
|
||||||
},
|
},
|
||||||
|
|
||||||
isValidEmail: function (email) {
|
root.isValidEmail = function (email) {
|
||||||
if (email.length > 255) {
|
if (email.length > 255) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +67,7 @@ module.exports = {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
randomSalt: function (length) {
|
root.randomSalt = function (length) {
|
||||||
var chars = "abcdefgihjklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
var chars = "abcdefgihjklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
+ "0123456789!@#$%^&*_+=~";
|
+ "0123456789!@#$%^&*_+=~";
|
||||||
var salt = [];
|
var salt = [];
|
||||||
|
|
@ -69,7 +77,7 @@ module.exports = {
|
||||||
return salt.join('');
|
return salt.join('');
|
||||||
},
|
},
|
||||||
|
|
||||||
maskIP: function (ip) {
|
root.maskIP = function (ip) {
|
||||||
if(ip.match(/^\d+\.\d+\.\d+\.\d+$/)) {
|
if(ip.match(/^\d+\.\d+\.\d+\.\d+$/)) {
|
||||||
// standard 32 bit IP
|
// standard 32 bit IP
|
||||||
return ip.replace(/\d+\.\d+\.(\d+\.\d+)/, "x.x.$1");
|
return ip.replace(/\d+\.\d+\.(\d+\.\d+)/, "x.x.$1");
|
||||||
|
|
@ -79,7 +87,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
formatTime: function (sec) {
|
root.formatTime = function (sec) {
|
||||||
if(sec === "--:--")
|
if(sec === "--:--")
|
||||||
return sec;
|
return sec;
|
||||||
|
|
||||||
|
|
@ -107,7 +115,7 @@ module.exports = {
|
||||||
return [h, m, s].join(":");
|
return [h, m, s].join(":");
|
||||||
},
|
},
|
||||||
|
|
||||||
newRateLimiter: function () {
|
root.newRateLimiter = function () {
|
||||||
return {
|
return {
|
||||||
count: 0,
|
count: 0,
|
||||||
lastTime: 0,
|
lastTime: 0,
|
||||||
|
|
@ -152,7 +160,7 @@ module.exports = {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
formatLink: function (id, type) {
|
root.formatLink = function (id, type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "yt":
|
case "yt":
|
||||||
return "http://youtu.be/" + id;
|
return "http://youtu.be/" + id;
|
||||||
|
|
@ -181,7 +189,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
isLive: function (type) {
|
root.isLive = function (type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "li":
|
case "li":
|
||||||
case "tw":
|
case "tw":
|
||||||
|
|
@ -197,11 +205,12 @@ module.exports = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
Set: Set,
|
root.sha1 = function (data) {
|
||||||
|
if (!crypto) {
|
||||||
sha1: function (data) {
|
return "";
|
||||||
|
}
|
||||||
var shasum = crypto.createHash("sha1");
|
var shasum = crypto.createHash("sha1");
|
||||||
shasum.update(data);
|
shasum.update(data);
|
||||||
return shasum.digest("hex");
|
return shasum.digest("hex");
|
||||||
}
|
}
|
||||||
};
|
})();
|
||||||
|
|
|
||||||
|
|
@ -179,7 +179,15 @@ function handleSocketConfig(req, res) {
|
||||||
|
|
||||||
function handleUserAgreement(req, res) {
|
function handleUserAgreement(req, res) {
|
||||||
logRequest(req);
|
logRequest(req);
|
||||||
|
|
||||||
|
var loginName = false;
|
||||||
|
if (req.cookies.auth) {
|
||||||
|
loginName = req.cookies.auth.split(":")[0];
|
||||||
|
}
|
||||||
|
|
||||||
sendJade(res, "tos", {
|
sendJade(res, "tos", {
|
||||||
|
loggedIn: loginName !== false,
|
||||||
|
loginName: loginName,
|
||||||
domain: Config.get("http.domain")
|
domain: Config.get("http.domain")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -187,6 +195,11 @@ function handleUserAgreement(req, res) {
|
||||||
function handleContactPage(req, res) {
|
function handleContactPage(req, res) {
|
||||||
logRequest(req);
|
logRequest(req);
|
||||||
|
|
||||||
|
var loginName = false;
|
||||||
|
if (req.cookies.auth) {
|
||||||
|
loginName = req.cookies.auth.split(":")[0];
|
||||||
|
}
|
||||||
|
|
||||||
// Make a copy to prevent messing with the original
|
// Make a copy to prevent messing with the original
|
||||||
var contacts = Config.get("contacts").map(function (c) {
|
var contacts = Config.get("contacts").map(function (c) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -210,6 +223,8 @@ function handleContactPage(req, res) {
|
||||||
});
|
});
|
||||||
|
|
||||||
sendJade(res, "contact", {
|
sendJade(res, "contact", {
|
||||||
|
loggedIn: loginName !== false,
|
||||||
|
loginName: loginName,
|
||||||
contacts: contacts
|
contacts: contacts
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1596,6 +1596,8 @@ function genPermissionsEditor() {
|
||||||
makeOption("Edit MOTD", "motdedit", modplus, CHANNEL.perms.motdedit+"");
|
makeOption("Edit MOTD", "motdedit", modplus, CHANNEL.perms.motdedit+"");
|
||||||
makeOption("Edit chat filters", "filteredit", modplus, CHANNEL.perms.filteredit+"");
|
makeOption("Edit chat filters", "filteredit", modplus, CHANNEL.perms.filteredit+"");
|
||||||
makeOption("Import chat filters", "filterimport", modplus, CHANNEL.perms.filterimport+"");
|
makeOption("Import chat filters", "filterimport", modplus, CHANNEL.perms.filterimport+"");
|
||||||
|
makeOption("Edit chat emotes", "emoteedit", modplus, CHANNEL.perms.emoteedit+"");
|
||||||
|
makeOption("Import chat emotes", "emoteimport", modplus, CHANNEL.perms.emoteimport+"");
|
||||||
|
|
||||||
addDivider("Misc");
|
addDivider("Misc");
|
||||||
makeOption("Drink calls", "drink", modleader, CHANNEL.perms.drink+"");
|
makeOption("Drink calls", "drink", modleader, CHANNEL.perms.drink+"");
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue