Implement time parsing/formatting for channel settings
This commit is contained in:
parent
8305c235eb
commit
74cb1b3efc
4 changed files with 54 additions and 20 deletions
|
|
@ -125,13 +125,12 @@ ChatModule.prototype.restrictNewAccount = function restrictNewAccount(user, data
|
|||
if (user.account.effectiveRank < 2 && this.channel.modules.options) {
|
||||
const firstSeen = user.getFirstSeenTime();
|
||||
const opts = this.channel.modules.options;
|
||||
// TODO: configurable times
|
||||
if (firstSeen > Date.now() - opts.get("new_user_chat_delay")) {
|
||||
if (firstSeen > Date.now() - opts.get("new_user_chat_delay")*1000) {
|
||||
user.socket.emit("spamFiltered", {
|
||||
reason: "NEW_USER_CHAT"
|
||||
});
|
||||
return true;
|
||||
} else if ((firstSeen > Date.now() - opts.get("new_user_chat_link_delay"))
|
||||
} else if ((firstSeen > Date.now() - opts.get("new_user_chat_link_delay")*1000)
|
||||
&& data.msg.match(LINK)) {
|
||||
user.socket.emit("spamFiltered", {
|
||||
reason: "NEW_USER_CHAT_LINK"
|
||||
|
|
@ -201,7 +200,7 @@ ChatModule.prototype.handlePm = function (user, data) {
|
|||
msg: "You must be signed in to send PMs"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Restrict new accounts/IPs from chatting and posting links
|
||||
if (this.restrictNewAccount(user, data)) {
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@ function OptionsModule(channel) {
|
|||
torbanned: false, // Block connections from Tor exit nodes
|
||||
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: 10 * 60 * 1000, // Minimum account/IP age to chat
|
||||
new_user_chat_link_delay: 60 * 60 * 1000 // Minimum account/IP age to post links
|
||||
new_user_chat_delay: 10 * 60, // Minimum account/IP age to chat
|
||||
new_user_chat_link_delay: 60 * 60 // Minimum account/IP age to post links
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -274,14 +274,14 @@ OptionsModule.prototype.handleSetOptions = function (user, data) {
|
|||
}
|
||||
|
||||
if ("new_user_chat_delay" in data) {
|
||||
var delay = parseInt(data.new_user_chat_delay);
|
||||
var delay = data.new_user_chat_delay;
|
||||
if (!isNaN(delay) && delay >= 0) {
|
||||
this.opts.new_user_chat_delay = delay;
|
||||
}
|
||||
}
|
||||
|
||||
if ("new_user_chat_link_delay" in data) {
|
||||
var delay = parseInt(data.new_user_chat_link_delay);
|
||||
var delay = data.new_user_chat_link_delay;
|
||||
if (!isNaN(delay) && delay >= 0) {
|
||||
this.opts.new_user_chat_link_delay = delay;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue