Add eslint (#741)
This commit is contained in:
parent
953428cad5
commit
62417f7fb8
72 changed files with 305 additions and 323 deletions
|
|
@ -1,18 +1,15 @@
|
|||
var Account = require("../account");
|
||||
var ChannelModule = require("./module");
|
||||
var Flags = require("../flags");
|
||||
|
||||
function AccessControlModule(channel) {
|
||||
function AccessControlModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
}
|
||||
|
||||
AccessControlModule.prototype = Object.create(ChannelModule.prototype);
|
||||
|
||||
var pending = 0;
|
||||
AccessControlModule.prototype.onUserPreJoin = function (user, data, cb) {
|
||||
var chan = this.channel,
|
||||
opts = this.channel.modules.options;
|
||||
var self = this;
|
||||
if (user.socket.disconnected) {
|
||||
return cb("User disconnected", ChannelModule.DENY);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,35 @@
|
|||
var ChannelModule = require("./module");
|
||||
var Flags = require("../flags");
|
||||
|
||||
function AnonymousCheck(channel) {
|
||||
function AnonymousCheck(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
}
|
||||
|
||||
AnonymousCheck.prototype = Object.create(ChannelModule.prototype);
|
||||
|
||||
AnonymousCheck.prototype.onUserPreJoin = function (user, data, cb) {
|
||||
var chan = this.channel,
|
||||
opts = this.channel.modules.options;
|
||||
const opts = this.channel.modules.options;
|
||||
var anonymousBanned = opts.get("block_anonymous_users");
|
||||
|
||||
|
||||
if (user.socket.disconnected) {
|
||||
return cb("User disconnected", ChannelModule.DENY);
|
||||
}
|
||||
|
||||
|
||||
if(anonymousBanned && user.isAnonymous()) {
|
||||
user.socket.on("disconnect", function () {
|
||||
if (!user.is(Flags.U_IN_CHANNEL)) {
|
||||
cb("User disconnected", ChannelModule.DENY);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
user.socket.emit("errorMsg", { msg : "This channel has blocked anonymous users. Please provide a user name to join."});
|
||||
user.waitFlag(Flags.U_LOGGED_IN, function () {
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
});
|
||||
return;
|
||||
}
|
||||
else{
|
||||
});
|
||||
return;
|
||||
} else{
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = AnonymousCheck;
|
||||
module.exports = AnonymousCheck;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ var sio = require("socket.io");
|
|||
var db = require("../database");
|
||||
import * as ChannelStore from '../channel-storage/channelstore';
|
||||
import { ChannelStateSizeError } from '../errors';
|
||||
import Promise from 'bluebird';
|
||||
import { EventEmitter } from 'events';
|
||||
import { throttle } from '../util/throttle';
|
||||
import Logger from '../logger';
|
||||
|
|
@ -80,8 +79,11 @@ function Channel(name) {
|
|||
this.name = name;
|
||||
this.uniqueName = name.toLowerCase();
|
||||
this.modules = {};
|
||||
this.logger = new Logger.Logger(path.join(__dirname, "..", "..", "chanlogs",
|
||||
this.uniqueName + ".log"));
|
||||
this.logger = new Logger.Logger(
|
||||
path.join(
|
||||
__dirname, "..", "..", "chanlogs", this.uniqueName + ".log"
|
||||
)
|
||||
);
|
||||
this.users = [];
|
||||
this.refCounter = new ReferenceCounter(this);
|
||||
this.flags = 0;
|
||||
|
|
@ -419,8 +421,7 @@ Channel.prototype.acceptUser = function (user) {
|
|||
|
||||
this.logger.log("[login] Accepted connection from Tor exit at " +
|
||||
user.displayip);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
this.logger.log("[login] Accepted connection from " + user.displayip);
|
||||
}
|
||||
|
||||
|
|
@ -461,7 +462,7 @@ Channel.prototype.acceptUser = function (user) {
|
|||
self.sendUserMeta(self.users, user);
|
||||
// TODO: Drop legacy setAFK frame after a few months
|
||||
self.broadcastAll("setAFK", { name: user.getName(), afk: afk });
|
||||
})
|
||||
});
|
||||
user.on("effectiveRankChange", (newRank, oldRank) => {
|
||||
this.maybeResendUserlist(user, newRank, oldRank);
|
||||
});
|
||||
|
|
@ -555,7 +556,7 @@ Channel.prototype.sendUserMeta = function (users, user, minrank) {
|
|||
var self = this;
|
||||
var userdata = self.packUserData(user);
|
||||
users.filter(function (u) {
|
||||
return typeof minrank !== "number" || u.account.effectiveRank > minrank
|
||||
return typeof minrank !== "number" || u.account.effectiveRank > minrank;
|
||||
}).forEach(function (u) {
|
||||
if (u.account.globalRank >= 255) {
|
||||
u.socket.emit("setUserMeta", {
|
||||
|
|
@ -697,7 +698,6 @@ Channel.prototype.handleReadLog = function (user) {
|
|||
return;
|
||||
}
|
||||
|
||||
var shouldMaskIP = user.account.globalRank < 255;
|
||||
this.readLog(function (err, data) {
|
||||
if (err) {
|
||||
user.socket.emit("readChanLog", {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
var Config = require("../config");
|
||||
var User = require("../user");
|
||||
var XSS = require("../xss");
|
||||
var ChannelModule = require("./module");
|
||||
var util = require("../utilities");
|
||||
var Flags = require("../flags");
|
||||
var url = require("url");
|
||||
var counters = require("../counters");
|
||||
import { transformImgTags } from '../camo';
|
||||
import { Counter } from 'prom-client';
|
||||
|
||||
const SHADOW_TAG = "[shadow]";
|
||||
const LINK = /(\w+:\/\/(?:[^:\/\[\]\s]+|\[[0-9a-f:]+\])(?::\d+)?(?:\/[^\/\s]*)*)/ig;
|
||||
const LINK = /(\w+:\/\/(?:[^:/[\]\s]+|\[[0-9a-f:]+\])(?::\d+)?(?:\/[^/\s]*)*)/ig;
|
||||
const LINK_PLACEHOLDER = '\ueeee';
|
||||
const LINK_PLACEHOLDER_RE = /\ueeee/g;
|
||||
|
||||
|
|
@ -31,7 +29,7 @@ const MIN_ANTIFLOOD = {
|
|||
sustained: 10
|
||||
};
|
||||
|
||||
function ChatModule(channel) {
|
||||
function ChatModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.buffer = [];
|
||||
this.muted = new util.Set();
|
||||
|
|
@ -66,7 +64,7 @@ ChatModule.prototype.load = function (data) {
|
|||
}
|
||||
|
||||
if ("chatmuted" in data) {
|
||||
for (var i = 0; i < data.chatmuted.length; i++) {
|
||||
for (i = 0; i < data.chatmuted.length; i++) {
|
||||
this.muted.add(data.chatmuted[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -79,7 +77,7 @@ ChatModule.prototype.save = function (data) {
|
|||
data.chatmuted = Array.prototype.slice.call(this.muted);
|
||||
};
|
||||
|
||||
ChatModule.prototype.packInfo = function (data, isAdmin) {
|
||||
ChatModule.prototype.packInfo = function (data, _isAdmin) {
|
||||
data.chat = Array.prototype.slice.call(this.buffer);
|
||||
};
|
||||
|
||||
|
|
@ -231,7 +229,6 @@ ChatModule.prototype.handlePm = function (user, data) {
|
|||
return;
|
||||
}
|
||||
|
||||
var reallyTo = data.to;
|
||||
data.to = data.to.toLowerCase();
|
||||
|
||||
if (data.to === user.getLowerName()) {
|
||||
|
|
@ -383,7 +380,6 @@ ChatModule.prototype.formatMessage = function (username, data) {
|
|||
|
||||
ChatModule.prototype.filterMessage = function (msg) {
|
||||
var filters = this.channel.modules.filters.filters;
|
||||
var chan = this.channel;
|
||||
var convertLinks = this.channel.modules.options.get("enable_link_regex");
|
||||
var links = msg.match(LINK);
|
||||
var intermediate = msg.replace(LINK, LINK_PLACEHOLDER);
|
||||
|
|
@ -450,9 +446,11 @@ ChatModule.prototype.sendMessage = function (msgobj) {
|
|||
this.buffer.shift();
|
||||
}
|
||||
|
||||
this.channel.logger.log("<" + msgobj.username + (msgobj.meta.addClass ?
|
||||
"." + msgobj.meta.addClass : "") +
|
||||
"> " + XSS.decodeText(msgobj.msg));
|
||||
this.channel.logger.log(
|
||||
"<" + msgobj.username +
|
||||
(msgobj.meta.addClass ? "." + msgobj.meta.addClass : "") +
|
||||
"> " + XSS.decodeText(msgobj.msg)
|
||||
);
|
||||
};
|
||||
|
||||
ChatModule.prototype.registerCommand = function (cmd, cb) {
|
||||
|
|
@ -491,7 +489,7 @@ ChatModule.prototype.handleCmdSay = function (user, msg, meta) {
|
|||
this.processChatMsg(user, { msg: args.join(" "), meta: meta });
|
||||
};
|
||||
|
||||
ChatModule.prototype.handleCmdClear = function (user, msg, meta) {
|
||||
ChatModule.prototype.handleCmdClear = function (user, _msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canClearChat(user)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -532,11 +530,11 @@ ChatModule.prototype.handleCmdAdminflair = function (user, msg, meta) {
|
|||
this.processChatMsg(user, { msg: cargs.join(" "), meta: meta });
|
||||
};
|
||||
|
||||
ChatModule.prototype.handleCmdAfk = function (user, msg, meta) {
|
||||
ChatModule.prototype.handleCmdAfk = function (user, _msg, _meta) {
|
||||
user.setAFK(!user.is(Flags.U_AFK));
|
||||
};
|
||||
|
||||
ChatModule.prototype.handleCmdMute = function (user, msg, meta) {
|
||||
ChatModule.prototype.handleCmdMute = function (user, msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canMute(user)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -586,7 +584,7 @@ ChatModule.prototype.handleCmdMute = function (user, msg, meta) {
|
|||
this.sendModMessage(user.getName() + " muted " + target.getName(), muteperm);
|
||||
};
|
||||
|
||||
ChatModule.prototype.handleCmdSMute = function (user, msg, meta) {
|
||||
ChatModule.prototype.handleCmdSMute = function (user, msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canMute(user)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -637,7 +635,7 @@ ChatModule.prototype.handleCmdSMute = function (user, msg, meta) {
|
|||
this.sendModMessage(user.getName() + " shadowmuted " + target.getName(), muteperm);
|
||||
};
|
||||
|
||||
ChatModule.prototype.handleCmdUnmute = function (user, msg, meta) {
|
||||
ChatModule.prototype.handleCmdUnmute = function (user, msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canMute(user)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ const TYPE_SETMOTD = {
|
|||
motd: "string"
|
||||
};
|
||||
|
||||
function CustomizationModule(channel) {
|
||||
function CustomizationModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.css = "";
|
||||
this.js = "";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
// TODO: figure out what to do with this module
|
||||
// it serves a very niche use case and is only a core module because of
|
||||
// legacy reasons (early channels requested it before I had criteria
|
||||
// around what to include in core)
|
||||
var ChannelModule = require("./module");
|
||||
|
||||
function DrinkModule(channel) {
|
||||
function DrinkModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.drinks = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,12 @@ EmoteList.prototype = {
|
|||
},
|
||||
|
||||
emoteExists: function (emote){
|
||||
if(this.emotes.filter((item)=>{ return item.name === emote.name }).length){
|
||||
return true;
|
||||
for (let i = 0; i < this.emotes.length; i++) {
|
||||
if (this.emotes[i].name === emote.name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
|
|
@ -61,7 +64,6 @@ EmoteList.prototype = {
|
|||
},
|
||||
|
||||
removeEmote: function (emote) {
|
||||
var found = false;
|
||||
for (var i = 0; i < this.emotes.length; i++) {
|
||||
if (this.emotes[i].name === emote.name) {
|
||||
this.emotes.splice(i, 1);
|
||||
|
|
@ -99,7 +101,7 @@ function validateEmote(f) {
|
|||
f.image = f.image.substring(0, 1000);
|
||||
f.image = XSS.sanitizeText(f.image);
|
||||
|
||||
var s = XSS.looseSanitizeText(f.name).replace(/([\\\.\?\+\*\$\^\|\(\)\[\]\{\}])/g, "\\$1");
|
||||
var s = XSS.looseSanitizeText(f.name).replace(/([\\.?+*$^|()[\]{}])/g, "\\$1");
|
||||
s = "(^|\\s)" + s + "(?!\\S)";
|
||||
f.source = s;
|
||||
|
||||
|
|
@ -114,9 +116,9 @@ function validateEmote(f) {
|
|||
}
|
||||
|
||||
return f;
|
||||
};
|
||||
}
|
||||
|
||||
function EmoteModule(channel) {
|
||||
function EmoteModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.emotes = new EmoteList();
|
||||
this.supportsDirtyCheck = true;
|
||||
|
|
@ -153,7 +155,6 @@ EmoteModule.prototype.onUserPostJoin = function (user) {
|
|||
|
||||
EmoteModule.prototype.sendEmotes = function (users) {
|
||||
var f = this.emotes.pack();
|
||||
var chan = this.channel;
|
||||
users.forEach(function (u) {
|
||||
u.socket.emit("emoteList", f);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ const DEFAULT_FILTERS = [
|
|||
"<span class=\"spoiler\">\\1</span>")
|
||||
];
|
||||
|
||||
function ChatFilterModule(channel) {
|
||||
function ChatFilterModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.filters = new FilterList();
|
||||
this.supportsDirtyCheck = true;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const TYPE_UNBAN = {
|
|||
name: "string"
|
||||
};
|
||||
|
||||
function KickBanModule(channel) {
|
||||
function KickBanModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
|
||||
if (this.channel.modules.chat) {
|
||||
|
|
@ -39,16 +39,6 @@ function checkIPBan(cname, ip, cb) {
|
|||
});
|
||||
}
|
||||
|
||||
function checkNameBan(cname, name, cb) {
|
||||
db.channels.isNameBanned(cname, name, function (err, banned) {
|
||||
if (err) {
|
||||
cb(false);
|
||||
} else {
|
||||
cb(banned);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function checkBan(cname, ip, name, cb) {
|
||||
db.channels.isBanned(cname, ip, name, function (err, banned) {
|
||||
if (err) {
|
||||
|
|
@ -65,7 +55,6 @@ KickBanModule.prototype.onUserPreJoin = function (user, data, cb) {
|
|||
}
|
||||
|
||||
const cname = this.channel.name;
|
||||
const check = (user.getName() !== '') ? checkBan : checkIPBan;
|
||||
function callback(banned) {
|
||||
if (banned) {
|
||||
cb(null, ChannelModule.DENY);
|
||||
|
|
@ -162,7 +151,7 @@ KickBanModule.prototype.sendUnban = function (users, data) {
|
|||
});
|
||||
};
|
||||
|
||||
KickBanModule.prototype.handleCmdKick = function (user, msg, meta) {
|
||||
KickBanModule.prototype.handleCmdKick = function (user, msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canKick(user)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -206,7 +195,7 @@ KickBanModule.prototype.handleCmdKick = function (user, msg, meta) {
|
|||
}
|
||||
};
|
||||
|
||||
KickBanModule.prototype.handleCmdKickAnons = function (user, msg, meta) {
|
||||
KickBanModule.prototype.handleCmdKickAnons = function (user, _msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canKick(user)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -226,7 +215,7 @@ KickBanModule.prototype.handleCmdKickAnons = function (user, msg, meta) {
|
|||
};
|
||||
|
||||
/* /ban - name bans */
|
||||
KickBanModule.prototype.handleCmdBan = function (user, msg, meta) {
|
||||
KickBanModule.prototype.handleCmdBan = function (user, msg, _meta) {
|
||||
var args = msg.split(" ");
|
||||
args.shift(); /* shift off /ban */
|
||||
if (args.length === 0 || args[0].trim() === "") {
|
||||
|
|
@ -249,7 +238,7 @@ KickBanModule.prototype.handleCmdBan = function (user, msg, meta) {
|
|||
};
|
||||
|
||||
/* /ipban - bans name and IP addresses associated with it */
|
||||
KickBanModule.prototype.handleCmdIPBan = function (user, msg, meta) {
|
||||
KickBanModule.prototype.handleCmdIPBan = function (user, msg, _meta) {
|
||||
var args = msg.split(" ");
|
||||
args.shift(); /* shift off /ipban */
|
||||
if (args.length === 0 || args[0].trim() === "") {
|
||||
|
|
@ -325,8 +314,8 @@ KickBanModule.prototype.banName = async function banName(actor, name, reason) {
|
|||
|
||||
if (chan.modules.chat) {
|
||||
chan.modules.chat.sendModMessage(
|
||||
actor.getName() + " namebanned " + name,
|
||||
chan.modules.permissions.permissions.ban
|
||||
actor.getName() + " namebanned " + name,
|
||||
chan.modules.permissions.permissions.ban
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -364,14 +353,14 @@ KickBanModule.prototype.banIP = async function banIP(actor, ip, name, reason) {
|
|||
|
||||
var cloaked = util.cloakIP(ip);
|
||||
chan.logger.log(
|
||||
"[mod] " + actor.getName() + " banned " + cloaked +
|
||||
" (" + name + ")"
|
||||
"[mod] " + actor.getName() + " banned " + cloaked +
|
||||
" (" + name + ")"
|
||||
);
|
||||
|
||||
if (chan.modules.chat) {
|
||||
chan.modules.chat.sendModMessage(
|
||||
actor.getName() + " banned " + cloaked + " (" + name + ")",
|
||||
chan.modules.permissions.permissions.ban
|
||||
actor.getName() + " banned " + cloaked + " (" + name + ")",
|
||||
chan.modules.permissions.permissions.ban
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -379,10 +368,10 @@ KickBanModule.prototype.banIP = async function banIP(actor, ip, name, reason) {
|
|||
};
|
||||
|
||||
KickBanModule.prototype.banAll = async function banAll(
|
||||
actor,
|
||||
name,
|
||||
range,
|
||||
reason
|
||||
actor,
|
||||
name,
|
||||
range,
|
||||
reason
|
||||
) {
|
||||
reason = reason.substring(0, 255);
|
||||
|
||||
|
|
@ -411,7 +400,7 @@ KickBanModule.prototype.banAll = async function banAll(
|
|||
}
|
||||
|
||||
const promises = Array.from(toBan).map(ip =>
|
||||
this.banIP(actor, ip, name, reason)
|
||||
this.banIP(actor, ip, name, reason)
|
||||
);
|
||||
|
||||
if (!await dbIsNameBanned(chan.name, name)) {
|
||||
|
|
@ -451,8 +440,10 @@ KickBanModule.prototype.handleUnban = function (user, data) {
|
|||
self.channel.logger.log("[mod] " + user.getName() + " unbanned " + data.name);
|
||||
if (self.channel.modules.chat) {
|
||||
var banperm = self.channel.modules.permissions.permissions.ban;
|
||||
self.channel.modules.chat.sendModMessage(user.getName() + " unbanned " +
|
||||
data.name, banperm);
|
||||
self.channel.modules.chat.sendModMessage(
|
||||
user.getName() + " unbanned " + data.name,
|
||||
banperm
|
||||
);
|
||||
}
|
||||
self.channel.refCounter.unref("KickBanModule::handleUnban");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const TYPE_SEARCH_MEDIA = {
|
|||
query: "string"
|
||||
};
|
||||
|
||||
function LibraryModule(channel) {
|
||||
function LibraryModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
}
|
||||
|
||||
|
|
@ -67,7 +67,7 @@ LibraryModule.prototype.handleUncache = function (user, data) {
|
|||
|
||||
const chan = this.channel;
|
||||
chan.refCounter.ref("LibraryModule::handleUncache");
|
||||
db.channels.deleteFromLibrary(chan.name, data.id, function (err, res) {
|
||||
db.channels.deleteFromLibrary(chan.name, data.id, function (err, _res) {
|
||||
if (chan.dead) {
|
||||
return;
|
||||
} else if (err) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
var Vimeo = require("cytube-mediaquery/lib/provider/vimeo");
|
||||
var ChannelModule = require("./module");
|
||||
var Config = require("../config");
|
||||
var InfoGetter = require("../get-info");
|
||||
|
||||
const LOGGER = require('@calzoneman/jsli')('mediarefresher');
|
||||
|
||||
|
|
|
|||
|
|
@ -8,13 +8,13 @@ ChannelModule.prototype = {
|
|||
/**
|
||||
* Called when the channel is loading its data from a JSON object.
|
||||
*/
|
||||
load: function (data) {
|
||||
load: function (_data) {
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when the channel is saving its state to a JSON object.
|
||||
*/
|
||||
save: function (data) {
|
||||
save: function (_data) {
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
@ -27,7 +27,7 @@ ChannelModule.prototype = {
|
|||
/**
|
||||
* Called to pack info, e.g. for channel detail view
|
||||
*/
|
||||
packInfo: function (data, isAdmin) {
|
||||
packInfo: function (_data, _isAdmin) {
|
||||
|
||||
},
|
||||
|
||||
|
|
@ -37,40 +37,40 @@ ChannelModule.prototype = {
|
|||
* data is the data sent by the client with the joinChannel
|
||||
* packet.
|
||||
*/
|
||||
onUserPreJoin: function (user, data, cb) {
|
||||
onUserPreJoin: function (_user, _data, cb) {
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after a user has been accepted to the channel.
|
||||
*/
|
||||
onUserPostJoin: function (user) {
|
||||
onUserPostJoin: function (_user) {
|
||||
},
|
||||
|
||||
/**
|
||||
* Called after a user has been disconnected from the channel.
|
||||
*/
|
||||
onUserPart: function (user) {
|
||||
onUserPart: function (_user) {
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when a chatMsg event is received
|
||||
*/
|
||||
onUserPreChat: function (user, data, cb) {
|
||||
onUserPreChat: function (_user, _data, cb) {
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called before a new video begins playing
|
||||
*/
|
||||
onPreMediaChange: function (data, cb) {
|
||||
onPreMediaChange: function (_data, cb) {
|
||||
cb(null, ChannelModule.PASSTHROUGH);
|
||||
},
|
||||
|
||||
/**
|
||||
* Called when a new video begins playing
|
||||
*/
|
||||
onMediaChange: function (data) {
|
||||
onMediaChange: function (_data) {
|
||||
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ function realTypeOf(thing) {
|
|||
return thing === null ? 'null' : typeof thing;
|
||||
}
|
||||
|
||||
function OptionsModule(channel) {
|
||||
function OptionsModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.opts = {
|
||||
allow_voteskip: true, // Allow users to voteskip
|
||||
|
|
@ -28,7 +28,7 @@ function OptionsModule(channel) {
|
|||
password: false, // Channel password (false -> no password required for entry)
|
||||
allow_dupes: false, // Allow duplicate videos on the playlist
|
||||
torbanned: false, // Block connections from Tor exit nodes
|
||||
block_anonymous_users: false, //Only allow connections from registered users.
|
||||
block_anonymous_users: false, //Only allow connections from registered users.
|
||||
allow_ascii_control: false,// Allow ASCII control characters (\x00-\x1f)
|
||||
playlist_max_per_user: 0, // Maximum number of playlist items per user
|
||||
new_user_chat_delay: 0, // Minimum account/IP age to chat
|
||||
|
|
@ -50,10 +50,14 @@ OptionsModule.prototype.load = function (data) {
|
|||
}
|
||||
}
|
||||
|
||||
this.opts.chat_antiflood_params.burst = Math.min(20,
|
||||
this.opts.chat_antiflood_params.burst);
|
||||
this.opts.chat_antiflood_params.sustained = Math.min(10,
|
||||
this.opts.chat_antiflood_params.sustained);
|
||||
this.opts.chat_antiflood_params.burst = Math.min(
|
||||
20,
|
||||
this.opts.chat_antiflood_params.burst
|
||||
);
|
||||
this.opts.chat_antiflood_params.sustained = Math.min(
|
||||
10,
|
||||
this.opts.chat_antiflood_params.sustained
|
||||
);
|
||||
this.dirty = false;
|
||||
};
|
||||
|
||||
|
|
@ -164,7 +168,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
if ("maxlength" in data) {
|
||||
var ml = 0;
|
||||
if (typeof data.maxlength !== "number") {
|
||||
ml = Utilities.parseTime(data.maxlength);
|
||||
ml = Utilities.parseTime(data.maxlength);
|
||||
} else {
|
||||
ml = parseInt(data.maxlength);
|
||||
}
|
||||
|
|
@ -206,13 +210,13 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
target: "#cs-externalcss"
|
||||
});
|
||||
} else {
|
||||
var data = url.parse(link);
|
||||
if (!data.protocol || data.protocol !== 'https:') {
|
||||
var urldata = url.parse(link);
|
||||
if (!urldata.protocol || urldata.protocol !== 'https:') {
|
||||
user.socket.emit("validationError", {
|
||||
target: "#cs-externalcss",
|
||||
message: prefix + " URL must begin with 'https://'"
|
||||
});
|
||||
} else if (!data.host) {
|
||||
} else if (!urldata.host) {
|
||||
user.socket.emit("validationError", {
|
||||
target: "#cs-externalcss",
|
||||
message: prefix + "missing hostname"
|
||||
|
|
@ -221,14 +225,14 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
user.socket.emit("validationPassed", {
|
||||
target: "#cs-externalcss"
|
||||
});
|
||||
this.opts.externalcss = data.href;
|
||||
this.opts.externalcss = urldata.href;
|
||||
sendUpdate = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ("externaljs" in data && user.account.effectiveRank >= 3) {
|
||||
var prefix = "Invalid URL for external JS: ";
|
||||
const prefix = "Invalid URL for external JS: ";
|
||||
if (typeof data.externaljs !== "string") {
|
||||
user.socket.emit("validationError", {
|
||||
target: "#cs-externaljs",
|
||||
|
|
@ -237,7 +241,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
});
|
||||
}
|
||||
|
||||
var link = data.externaljs.substring(0, 255).trim();
|
||||
const link = data.externaljs.substring(0, 255).trim();
|
||||
if (!link) {
|
||||
sendUpdate = (this.opts.externaljs !== "");
|
||||
this.opts.externaljs = "";
|
||||
|
|
@ -245,13 +249,13 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
target: "#cs-externaljs"
|
||||
});
|
||||
} else {
|
||||
var data = url.parse(link);
|
||||
if (!data.protocol || data.protocol !== 'https:') {
|
||||
const urldata = url.parse(link);
|
||||
if (!urldata.protocol || urldata.protocol !== 'https:') {
|
||||
user.socket.emit("validationError", {
|
||||
target: "#cs-externaljs",
|
||||
message: prefix + " URL must begin with 'https://'"
|
||||
});
|
||||
} else if (!data.host) {
|
||||
} else if (!urldata.host) {
|
||||
user.socket.emit("validationError", {
|
||||
target: "#cs-externaljs",
|
||||
message: prefix + "missing hostname"
|
||||
|
|
@ -260,7 +264,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
user.socket.emit("validationPassed", {
|
||||
target: "#cs-externaljs"
|
||||
});
|
||||
this.opts.externaljs = data.href;
|
||||
this.opts.externaljs = urldata.href;
|
||||
sendUpdate = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -333,7 +337,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
this.opts.block_anonymous_users = Boolean(data.block_anonymous_users);
|
||||
sendUpdate = true;
|
||||
}
|
||||
|
||||
|
||||
if ("allow_ascii_control" in data && user.account.effectiveRank >= 3) {
|
||||
this.opts.allow_ascii_control = Boolean(data.allow_ascii_control);
|
||||
sendUpdate = true;
|
||||
|
|
@ -348,7 +352,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
}
|
||||
|
||||
if ("new_user_chat_delay" in data) {
|
||||
var delay = data.new_user_chat_delay;
|
||||
const delay = data.new_user_chat_delay;
|
||||
if (!isNaN(delay) && delay >= 0) {
|
||||
this.opts.new_user_chat_delay = delay;
|
||||
sendUpdate = true;
|
||||
|
|
@ -356,7 +360,7 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
}
|
||||
|
||||
if ("new_user_chat_link_delay" in data) {
|
||||
var delay = data.new_user_chat_link_delay;
|
||||
const delay = data.new_user_chat_link_delay;
|
||||
if (!isNaN(delay) && delay >= 0) {
|
||||
this.opts.new_user_chat_link_delay = delay;
|
||||
sendUpdate = true;
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ const DEFAULT_PERMISSIONS = {
|
|||
exceedmaxdurationperuser: 2 // Exceed maximum total playlist length per user
|
||||
};
|
||||
|
||||
function PermissionsModule(channel) {
|
||||
function PermissionsModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.permissions = {};
|
||||
this.openPlaylist = false;
|
||||
|
|
@ -148,7 +148,7 @@ PermissionsModule.prototype.handleSetPermissions = function (user, perms) {
|
|||
return;
|
||||
}
|
||||
|
||||
for (var key in perms) {
|
||||
for (const key in perms) {
|
||||
if (typeof perms[key] !== "number") {
|
||||
perms[key] = parseFloat(perms[key]);
|
||||
if (isNaN(perms[key])) {
|
||||
|
|
@ -157,7 +157,7 @@ PermissionsModule.prototype.handleSetPermissions = function (user, perms) {
|
|||
}
|
||||
}
|
||||
|
||||
for (var key in perms) {
|
||||
for (const key in perms) {
|
||||
if (key in this.permissions) {
|
||||
this.permissions[key] = perms[key];
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ PermissionsModule.prototype.canMoveVideo = function (account) {
|
|||
};
|
||||
|
||||
PermissionsModule.prototype.canDeleteVideo = function (account) {
|
||||
return this.hasPermission(account, "playlistdelete")
|
||||
return this.hasPermission(account, "playlistdelete");
|
||||
};
|
||||
|
||||
PermissionsModule.prototype.canSkipVideo = function (account) {
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ PlaylistItem.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
function PlaylistModule(channel) {
|
||||
function PlaylistModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
this.items = new ULList();
|
||||
this.meta = {
|
||||
|
|
@ -541,7 +541,6 @@ PlaylistModule.prototype.queueStandard = function (user, data) {
|
|||
}
|
||||
|
||||
function handleLookup() {
|
||||
var channelName = self.channel.name;
|
||||
InfoGetter.getMedia(data.id, data.type, function (err, media) {
|
||||
if (err) {
|
||||
error(XSS.sanitizeText(String(err)));
|
||||
|
|
@ -795,7 +794,7 @@ PlaylistModule.prototype.handleShuffle = function (user) {
|
|||
this.channel.users.forEach(function (u) {
|
||||
if (perms.canSeePlaylist(u)) {
|
||||
u.socket.emit("playlist", pl);
|
||||
};
|
||||
}
|
||||
});
|
||||
this.startPlayback();
|
||||
};
|
||||
|
|
@ -1069,16 +1068,6 @@ PlaylistModule.prototype._addItem = function (media, data, user, cb) {
|
|||
}
|
||||
};
|
||||
|
||||
function isExpired(media) {
|
||||
if (media.meta.expiration && media.meta.expiration < Date.now()) {
|
||||
return true;
|
||||
} else if (media.type === "gd") {
|
||||
return !media.meta.object;
|
||||
} else if (media.type === "vi") {
|
||||
return !media.meta.direct;
|
||||
}
|
||||
}
|
||||
|
||||
PlaylistModule.prototype.startPlayback = function (time) {
|
||||
var self = this;
|
||||
|
||||
|
|
@ -1150,7 +1139,7 @@ PlaylistModule.prototype.startPlayback = function (time) {
|
|||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
const UPDATE_INTERVAL = Config.get("playlist.update-interval");
|
||||
|
||||
|
|
@ -1232,7 +1221,7 @@ PlaylistModule.prototype.clean = function (test) {
|
|||
* -flags)
|
||||
*/
|
||||
function generateTargetRegex(target) {
|
||||
const flagsre = /^(-[img]+\s+)/i
|
||||
const flagsre = /^(-[img]+\s+)/i;
|
||||
var m = target.match(flagsre);
|
||||
var flags = "";
|
||||
if (m) {
|
||||
|
|
@ -1242,7 +1231,7 @@ function generateTargetRegex(target) {
|
|||
return new RegExp(target, flags);
|
||||
}
|
||||
|
||||
PlaylistModule.prototype.handleClean = function (user, msg, meta) {
|
||||
PlaylistModule.prototype.handleClean = function (user, msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canDeleteVideo(user)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ const TYPE_VOTE = {
|
|||
const ROOM_VIEW_HIDDEN = ":viewHidden";
|
||||
const ROOM_NO_VIEW_HIDDEN = ":noViewHidden";
|
||||
|
||||
function PollModule(channel) {
|
||||
function PollModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
|
||||
this.poll = null;
|
||||
|
|
@ -125,7 +125,6 @@ PollModule.prototype.broadcastPoll = function (isNewPoll) {
|
|||
|
||||
var obscured = this.poll.packUpdate(false);
|
||||
var unobscured = this.poll.packUpdate(true);
|
||||
var perms = this.channel.modules.permissions;
|
||||
|
||||
const event = isNewPoll ? "newPoll" : "updatePoll";
|
||||
if (isNewPoll) {
|
||||
|
|
@ -192,7 +191,7 @@ PollModule.prototype.handleNewPoll = function (user, data, ack) {
|
|||
poll.timer = setTimeout(function () {
|
||||
if (self.poll === poll) {
|
||||
self.handleClosePoll({
|
||||
getName: function () { return "[poll timer]" },
|
||||
getName: function () { return "[poll timer]"; },
|
||||
effectiveRank: 255
|
||||
});
|
||||
}
|
||||
|
|
@ -240,7 +239,7 @@ PollModule.prototype.handleClosePoll = function (user) {
|
|||
}
|
||||
};
|
||||
|
||||
PollModule.prototype.handlePollCmd = function (obscured, user, msg, meta) {
|
||||
PollModule.prototype.handlePollCmd = function (obscured, user, msg, _meta) {
|
||||
if (!this.channel.modules.permissions.canControlPoll(user)) {
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ const TYPE_SET_CHANNEL_RANK = {
|
|||
rank: "number"
|
||||
};
|
||||
|
||||
function RankModule(channel) {
|
||||
function RankModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
|
||||
if (this.channel.modules.chat) {
|
||||
|
|
@ -47,7 +47,7 @@ RankModule.prototype.sendChannelRanks = function (users) {
|
|||
});
|
||||
};
|
||||
|
||||
RankModule.prototype.handleCmdRank = function (user, msg, meta) {
|
||||
RankModule.prototype.handleCmdRank = function (user, msg, _meta) {
|
||||
var args = msg.split(" ");
|
||||
args.shift(); /* shift off /rank */
|
||||
var name = args.shift();
|
||||
|
|
@ -186,7 +186,6 @@ RankModule.prototype.updateDatabase = function (data, cb) {
|
|||
"You can't promote or demote someone" +
|
||||
" with equal or higher rank than you."
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
return dbSetChannelRank(chan.name, data.name, data.rank);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ var ChannelModule = require("./module");
|
|||
var Flags = require("../flags");
|
||||
var Poll = require("../poll").Poll;
|
||||
|
||||
function VoteskipModule(channel) {
|
||||
function VoteskipModule(_channel) {
|
||||
ChannelModule.apply(this, arguments);
|
||||
|
||||
this.poll = false;
|
||||
|
|
@ -128,7 +128,7 @@ VoteskipModule.prototype.reset = function reset() {
|
|||
this.sendVoteskipData(this.channel.users);
|
||||
};
|
||||
|
||||
VoteskipModule.prototype.onMediaChange = function (data) {
|
||||
VoteskipModule.prototype.onMediaChange = function (_data) {
|
||||
this.reset();
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue