disallow team ads in public chats - closes #2626
This commit is contained in:
parent
b6c65586f4
commit
9d23199d01
|
@ -17,7 +17,7 @@ data: @Html(J.stringify(data)),
|
|||
i18n: @jsI18n(),
|
||||
userId: @jsUserId,
|
||||
chat: @jsOrNull(chatOption map { c =>
|
||||
chat.ChatJsData.json(c.chat, name = trans.spectatorRoom.str(), timeout = c.timeout, withNote = ctx.isAuth)
|
||||
chat.ChatJsData.json(c.chat, name = trans.spectatorRoom.str(), timeout = c.timeout, withNote = ctx.isAuth, public = true)
|
||||
}),
|
||||
explorer: {
|
||||
endpoint: "@explorerEndpoint",
|
||||
|
|
|
@ -8,12 +8,25 @@ import lila.common.PimpedJson._
|
|||
|
||||
object ChatJsData {
|
||||
|
||||
def restricted(chat: lila.chat.Chat.Restricted, name: String, timeout: Boolean, withNote: Boolean = false, writeable: Boolean = true)(implicit ctx: Context) =
|
||||
def restricted(
|
||||
chat: lila.chat.Chat.Restricted,
|
||||
name: String,
|
||||
timeout: Boolean,
|
||||
public: Boolean, // game players chat is not public
|
||||
withNote: Boolean = false,
|
||||
writeable: Boolean = true)(implicit ctx: Context) =
|
||||
json(
|
||||
chat.chat, name = name, timeout = timeout, withNote = withNote, writeable = writeable, restricted = chat.restricted
|
||||
chat.chat, name = name, timeout = timeout, withNote = withNote, writeable = writeable, public = public, restricted = chat.restricted
|
||||
)
|
||||
|
||||
def json(chat: lila.chat.AnyChat, name: String, timeout: Boolean, withNote: Boolean = false, writeable: Boolean = true, restricted: Boolean = false)(implicit ctx: Context) = Json.obj(
|
||||
def json(
|
||||
chat: lila.chat.AnyChat,
|
||||
name: String,
|
||||
timeout: Boolean,
|
||||
public: Boolean, // game players chat is not public
|
||||
withNote: Boolean = false,
|
||||
writeable: Boolean = true,
|
||||
restricted: Boolean = false)(implicit ctx: Context) = Json.obj(
|
||||
"data" -> Json.obj(
|
||||
"id" -> chat.id,
|
||||
"name" -> name,
|
||||
|
@ -25,6 +38,7 @@ object ChatJsData {
|
|||
"i18n" -> i18n(withNote = withNote),
|
||||
"writeable" -> writeable,
|
||||
"noteId" -> withNote.option(chat.id take 8),
|
||||
"public" -> public,
|
||||
"kobold" -> ctx.troll,
|
||||
"permissions" -> Json.obj(
|
||||
"timeout" -> isGranted(_.ChatTimeout).option(true),
|
||||
|
|
|
@ -12,7 +12,7 @@ data: @Html(J.stringify(data)),
|
|||
i18n: @jsI18n(),
|
||||
userId: @jsUserId,
|
||||
chat: @jsOrNull(chatOption map { c =>
|
||||
chat.ChatJsData.restricted(c, name = trans.chatRoom.str(), timeout = false, withNote = true)
|
||||
chat.ChatJsData.restricted(c, name = trans.chatRoom.str(), timeout = false, withNote = true, public = false)
|
||||
})
|
||||
});
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ lichess.startRound(document.getElementById('lichess'), {
|
|||
data: @Html(J.stringify(data)),
|
||||
i18n: @jsI18n(),
|
||||
chat: @jsOrNull(chatOption map { c =>
|
||||
chat.ChatJsData.json(c.chat, name = trans.spectatorRoom.str(), timeout = c.timeout, withNote = ctx.isAuth)
|
||||
chat.ChatJsData.json(c.chat, name = trans.spectatorRoom.str(), timeout = c.timeout, withNote = ctx.isAuth, public = true)
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,7 +15,7 @@ i18n: @jsI18n(),
|
|||
socketVersion: @socketVersion,
|
||||
userId: @jsUserId,
|
||||
chat: @jsOrNull(chatOption map { c =>
|
||||
chat.ChatJsData.json(c.chat, name = trans.chatRoom.str(), timeout = c.timeout)
|
||||
chat.ChatJsData.json(c.chat, name = trans.chatRoom.str(), timeout = c.timeout, public = true)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ i18n: @board.userAnalysisI18n(),
|
|||
tagTypes: '@lila.study.PgnTags.typesToString',
|
||||
userId: @jsUserId,
|
||||
chat: @jsOrNull(chatOption map { c =>
|
||||
chat.ChatJsData.json(c.chat, name = trans.chatRoom.str(), timeout = c.timeout, writeable = ctx.userId.??(s.canChat))
|
||||
chat.ChatJsData.json(c.chat, name = trans.chatRoom.str(), timeout = c.timeout, writeable = ctx.userId.??(s.canChat), public = false)
|
||||
}),
|
||||
explorer: {
|
||||
endpoint: "@explorerEndpoint",
|
||||
|
|
|
@ -15,7 +15,7 @@ data: @Html(play.api.libs.json.Json.stringify(data)),
|
|||
i18n: @jsI18n(),
|
||||
userId: @jsUserId,
|
||||
chat: @jsOrNull(chatOption map { c =>
|
||||
chat.ChatJsData.json(c.chat, name = trans.chatRoom.str(), timeout = c.timeout)
|
||||
chat.ChatJsData.json(c.chat, name = trans.chatRoom.str(), timeout = c.timeout, public = true)
|
||||
})
|
||||
};
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ module.exports = function(opts) {
|
|||
preset: preset,
|
||||
post: post,
|
||||
trans: trans,
|
||||
public: opts.public,
|
||||
setEnabled: function(v) {
|
||||
vm.enabled(v);
|
||||
emitEnabled();
|
||||
|
|
|
@ -64,8 +64,10 @@ function input(ctrl) {
|
|||
var kbm = document.querySelector('.keyboard-move input');
|
||||
if (kbm) kbm.focus();
|
||||
} else {
|
||||
spam.report(e.target.value);
|
||||
ctrl.post(e.target.value);
|
||||
var txt = e.target.value;
|
||||
spam.report(txt);
|
||||
if (ctrl.public && spam.hasTeamUrl(txt)) alert("Please don't advertise teams in the chat.");
|
||||
else ctrl.post(txt);
|
||||
e.target.value = '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
var isSpammer = lichess.storage.make('spammer');
|
||||
|
||||
var regex = new RegExp([
|
||||
var spamRegex = new RegExp([
|
||||
'xcamweb.com',
|
||||
'chess-bot',
|
||||
'coolteenbitch',
|
||||
|
@ -19,10 +19,15 @@ var regex = new RegExp([
|
|||
}).join('|'));
|
||||
|
||||
function analyse(txt) {
|
||||
return !!txt.match(regex);
|
||||
return !!txt.match(spamRegex);
|
||||
}
|
||||
|
||||
var teamUrlRegex = /lichess\.org\/team\//
|
||||
|
||||
module.exports = {
|
||||
hasTeamUrl: function(txt) {
|
||||
return !!txt.match(teamUrlRegex);
|
||||
},
|
||||
skip: function(txt) {
|
||||
return analyse(txt) && isSpammer.get() != '1';
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue