remove lobby chat
This commit is contained in:
parent
f6c0b4e4dc
commit
3b363821a2
|
@ -12,7 +12,6 @@ final class Env(config: Config, system: ActorSystem) {
|
|||
|
||||
lazy val preloader = new mashup.Preload(
|
||||
lobby = Env.lobby.lobby,
|
||||
messenger = Env.lobby.messenger,
|
||||
history = Env.lobby.history,
|
||||
featured = Env.game.featured)
|
||||
|
||||
|
|
|
@ -45,8 +45,4 @@ object Lobby extends LilaController with Results {
|
|||
Env.lobby.socketHandler(uid = uid, user = ctx.me)
|
||||
}
|
||||
}
|
||||
|
||||
def log = Open { implicit ctx ⇒
|
||||
Env.lobby.messenger.recent(ctx.troll, 200) map { html.lobby.log(_) }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.app
|
||||
package mashup
|
||||
|
||||
import lila.lobby.{ Hook, HookRepo, Messenger }
|
||||
import lila.lobby.{ Hook, HookRepo }
|
||||
import lila.lobby.actorApi.lobby._
|
||||
import lila.timeline.Entry
|
||||
import lila.game.{ Game, GameRepo, Featured }
|
||||
|
@ -20,7 +20,6 @@ import play.api.libs.json.{ Json, JsObject, JsArray }
|
|||
|
||||
final class Preload(
|
||||
lobby: ActorRef,
|
||||
messenger: Messenger,
|
||||
history: History,
|
||||
featured: Featured) {
|
||||
|
||||
|
@ -33,18 +32,12 @@ final class Preload(
|
|||
tours: Fu[List[Created]],
|
||||
filter: Fu[FilterConfig])(implicit ctx: Context): Fu[Response] =
|
||||
ctx.isAuth.fold(lobby ? GetOpen, lobby ? GetOpenCasual).mapTo[List[Hook]] zip
|
||||
(ctx.canSeeChat ?? messenger.recent(ctx.troll, 20)) zip
|
||||
timeline zip posts zip tours zip featured.one zip filter map {
|
||||
case ((((((hooks, messages), entries), posts), tours), feat), filter) ⇒
|
||||
case (((((hooks, entries), posts), tours), feat), filter) ⇒
|
||||
(Right((Json.obj(
|
||||
"version" -> history.version,
|
||||
"pool" -> renderHooks(hooks),
|
||||
"chat" -> (messages.reverse map (_.render)),
|
||||
"pool" -> JsArray(hooks map (_.render)),
|
||||
"filter" -> filter.render
|
||||
), entries, posts, tours, feat)))
|
||||
}
|
||||
|
||||
private def renderHooks(hooks: List[Hook]): JsArray = JsArray {
|
||||
hooks map (_.render)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,5 @@
|
|||
@(preload: String, timeline: List[lila.timeline.Entry], forumRecent: List[lila.forum.PostLiteView], tours: List[lila.tournament.Created], featured: Option[Game])(implicit ctx: Context)
|
||||
|
||||
@chat = {
|
||||
@ctx.me.map { me =>
|
||||
@base.chatRoom(
|
||||
title = trans.chatRoom.str(),
|
||||
cssClass = "lobby_chat") {
|
||||
<li><a href="@routes.Lobby.log()">View older messages</a></li>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@underchat = {
|
||||
<div id="featured_game">
|
||||
@featured.map { g =>
|
||||
|
@ -26,7 +16,6 @@ cssClass = "lobby_chat") {
|
|||
title = "",
|
||||
baseline = baseline.some,
|
||||
active = siteMenu.play.some,
|
||||
chat = chat.some,
|
||||
underchat = underchat.some) {
|
||||
<div id="call_boxes">
|
||||
@translationCall.map(i18n.callBox(_))
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
@(messages: List[lila.lobby.Message])(implicit ctx: Context)
|
||||
|
||||
@title = @{ "Chat logs" }
|
||||
|
||||
@base.layout(title = title) {
|
||||
|
||||
<div class="content_box">
|
||||
<h1>@title</h1>
|
||||
<br /><br />
|
||||
<table class="datatable"><tbody>
|
||||
@messages.map { message =>
|
||||
<tr>
|
||||
<td>@showDate(message.date)</td>
|
||||
<td>@usernameLink(message.user)</td>
|
||||
<td>@Html(message.text)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody></table>
|
||||
</div>
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
# Lobby
|
||||
GET / controllers.Lobby.home
|
||||
GET /lobby/socket controllers.Lobby.socket
|
||||
GET /lobby/log controllers.Lobby.log
|
||||
|
||||
# User
|
||||
POST /@/:username/export controllers.User.export(username: String)
|
||||
|
|
|
@ -11,15 +11,12 @@ final class Env(
|
|||
config: Config,
|
||||
db: lila.db.Env,
|
||||
hub: lila.hub.Env,
|
||||
flood: lila.security.Flood,
|
||||
roundMessenger: lila.round.Messenger,
|
||||
system: ActorSystem,
|
||||
scheduler: lila.common.Scheduler) {
|
||||
|
||||
private val settings = new {
|
||||
val MessageMax = config getInt "message.max"
|
||||
val MessageTtl = config duration "message.ttl"
|
||||
val CollectionMessage = config getString "collection.message"
|
||||
val NetDomain = config getString "net.domain"
|
||||
val SocketName = config getString "socket.name"
|
||||
val SocketUidTtl = config duration "socket.uid.ttl"
|
||||
|
@ -29,7 +26,6 @@ final class Env(
|
|||
import settings._
|
||||
|
||||
private val socket = system.actorOf(Props(new Socket(
|
||||
messenger = messenger,
|
||||
history = history,
|
||||
router = hub.actor.router,
|
||||
uidTtl = SocketUidTtl
|
||||
|
@ -42,10 +38,7 @@ final class Env(
|
|||
|
||||
lazy val socketHandler = new SocketHandler(
|
||||
lobby = lobby,
|
||||
socket = socket,
|
||||
messenger = messenger)
|
||||
|
||||
lazy val messenger = new Messenger(flood = flood, netDomain = NetDomain)
|
||||
socket = socket)
|
||||
|
||||
lazy val history = new History(ttl = MessageTtl)
|
||||
|
||||
|
@ -64,8 +57,6 @@ final class Env(
|
|||
private lazy val biter = new Biter(
|
||||
timeline = hub.actor.timeline,
|
||||
roundMessenger = roundMessenger)
|
||||
|
||||
private[lobby] lazy val messageColl = db(CollectionMessage)
|
||||
}
|
||||
|
||||
object Env {
|
||||
|
@ -74,7 +65,6 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "lobby",
|
||||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
flood = lila.security.Env.current.flood,
|
||||
roundMessenger = lila.round.Env.current.messenger,
|
||||
system = lila.common.PlayApp.system,
|
||||
scheduler = lila.common.PlayApp.scheduler)
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package lila.lobby
|
||||
|
||||
import play.api.libs.json._
|
||||
import reactivemongo.bson._
|
||||
import org.joda.time.DateTime
|
||||
|
||||
// it is really a username, not a user ID
|
||||
case class Message(
|
||||
user: Option[String],
|
||||
text: String,
|
||||
troll: Boolean,
|
||||
date: DateTime) {
|
||||
|
||||
def render = Json.obj("u" -> user, "t" -> text)
|
||||
|
||||
def isEmpty = text.isEmpty
|
||||
}
|
||||
|
||||
object Message {
|
||||
|
||||
def make(user: Option[String], text: String, troll: Boolean) = new Message(
|
||||
user = user,
|
||||
text = text,
|
||||
troll = troll,
|
||||
date = DateTime.now)
|
||||
|
||||
import lila.db.Tube
|
||||
import Tube.Helpers._
|
||||
|
||||
private def defaults = Json.obj("user" -> none[String])
|
||||
|
||||
private[lobby] lazy val tube = Tube[Message](
|
||||
(__.json update (merge(defaults) andThen readDate('date))) andThen Json.reads[Message],
|
||||
Json.writes[Message] andThen (__.json update writeDate('date)),
|
||||
flags = Seq(_.NoId))
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package lila.lobby
|
||||
|
||||
import lila.user.{ UserRepo, User, Room }
|
||||
import tube.messageTube
|
||||
import lila.db.api._
|
||||
import lila.db.Implicits._
|
||||
import lila.security.Flood
|
||||
|
||||
import play.api.libs.json.Json
|
||||
import org.apache.commons.lang3.StringEscapeUtils.escapeXml
|
||||
|
||||
final class Messenger(
|
||||
flood: Flood,
|
||||
val netDomain: String) extends Room {
|
||||
|
||||
def apply(userId: String, text: String): Fu[Option[Message]] =
|
||||
UserRepo byId userId flatten "[lobby] messenger no such user" flatMap { user ⇒
|
||||
if (flood.allowMessage(userId, text)) for {
|
||||
message ← (userMessage(user.some, text) map {
|
||||
case (u, t) ⇒ Message.make(user.id.some, escapeXml(t), user.troll)
|
||||
}).future
|
||||
_ ← $insert(message)
|
||||
} yield message.some
|
||||
else fuloginfo("[lobby] %s is flooding the lobby room" format userId) inject none
|
||||
}
|
||||
|
||||
def system(text: String): Fu[Message] =
|
||||
Message.make(user = none, text = text, troll = false) |> { message ⇒
|
||||
$insert(message) inject message
|
||||
}
|
||||
|
||||
def recent(withTrolls: Boolean, limit: Int): Fu[List[Message]] =
|
||||
$query(withTrolls.fold(
|
||||
$select.all,
|
||||
Json.obj("troll" -> false)
|
||||
)) sort $sort.naturalOrder toListFlatten limit.some
|
||||
}
|
|
@ -16,7 +16,6 @@ import play.api.templates.Html
|
|||
import scala.concurrent.duration._
|
||||
|
||||
private[lobby] final class Socket(
|
||||
messenger: Messenger,
|
||||
val history: History,
|
||||
router: lila.hub.ActorLazyRef,
|
||||
uidTtl: Duration) extends SocketActor[Member](uidTtl) with Historical[Member] {
|
||||
|
@ -37,20 +36,6 @@ private[lobby] final class Socket(
|
|||
sender ! Connected(enumerator, member)
|
||||
}
|
||||
|
||||
case Message(user, text, troll, _) ⇒ notifyVersion("talk",
|
||||
Json.obj("u" -> user, "t" -> text) |> { obj ⇒
|
||||
troll.fold(obj + ("troll" -> JsBoolean(true)), obj)
|
||||
}
|
||||
)
|
||||
|
||||
case SysTalk(txt) ⇒ messenger system txt foreach { message ⇒
|
||||
notifyVersion("talk", Json.obj("t" -> message.text))
|
||||
}
|
||||
|
||||
case UnTalk(regex) ⇒ notifyVersion("untalk", Json.obj(
|
||||
"regex" -> regex.toString
|
||||
))
|
||||
|
||||
case ReloadTournaments(html) ⇒ notifyTournaments(html)
|
||||
|
||||
case TimelineEntry(rendered) ⇒ notifyVersion("entry", rendered)
|
||||
|
|
|
@ -15,8 +15,7 @@ import play.api.libs.iteratee._
|
|||
|
||||
private[lobby] final class SocketHandler(
|
||||
lobby: ActorRef,
|
||||
socket: ActorRef,
|
||||
messenger: Messenger) {
|
||||
socket: ActorRef) {
|
||||
|
||||
private def controller(
|
||||
socket: ActorRef,
|
||||
|
@ -27,12 +26,6 @@ private[lobby] final class SocketHandler(
|
|||
lobby ! BiteHook(id, uid, member.userId)
|
||||
}
|
||||
case ("cancel", o) ⇒ lobby ! CancelHook(uid)
|
||||
case ("talk", o) ⇒ for {
|
||||
userId ← member.userId
|
||||
text ← o str "d"
|
||||
} messenger(userId, text) logFailure "[lobby] message" foreach {
|
||||
_ foreach { socket ! _ }
|
||||
}
|
||||
case ("liveGames", o) ⇒ o str "d" foreach { ids ⇒
|
||||
socket ! LiveGames(uid, ids.split(' ').toList)
|
||||
}
|
||||
|
|
|
@ -2,11 +2,4 @@ package lila
|
|||
|
||||
import lila.socket.WithSocket
|
||||
|
||||
package object lobby extends PackageObject with WithPlay with WithSocket {
|
||||
|
||||
object tube {
|
||||
|
||||
private[lobby] implicit lazy val messageTube =
|
||||
Message.tube inColl Env.current.messageColl
|
||||
}
|
||||
}
|
||||
package object lobby extends PackageObject with WithPlay with WithSocket
|
||||
|
|
Loading…
Reference in a new issue