2013-12-26 12:30:57 -07:00
|
|
|
package lila.chat
|
|
|
|
|
2015-04-29 09:04:55 -06:00
|
|
|
import akka.actor.{ ActorSystem, Props, ActorSelection }
|
2013-12-26 12:30:57 -07:00
|
|
|
import com.typesafe.config.Config
|
|
|
|
|
|
|
|
final class Env(
|
|
|
|
config: Config,
|
|
|
|
db: lila.db.Env,
|
2014-01-31 15:54:34 -07:00
|
|
|
flood: lila.security.Flood,
|
2018-10-14 02:42:08 -06:00
|
|
|
spam: lila.security.Spam,
|
2015-04-29 09:04:55 -06:00
|
|
|
shutup: ActorSelection,
|
2016-06-10 18:22:52 -06:00
|
|
|
modLog: ActorSelection,
|
2017-08-17 16:49:11 -06:00
|
|
|
asyncCache: lila.memo.AsyncCache.Builder,
|
2017-02-14 08:34:07 -07:00
|
|
|
system: ActorSystem
|
|
|
|
) {
|
2013-12-26 12:30:57 -07:00
|
|
|
|
|
|
|
private val settings = new {
|
2014-01-28 07:45:28 -07:00
|
|
|
val CollectionChat = config getString "collection.chat"
|
2016-06-10 09:15:00 -06:00
|
|
|
val CollectionTimeout = config getString "collection.timeout"
|
2014-01-28 17:42:38 -07:00
|
|
|
val MaxLinesPerChat = config getInt "max_lines"
|
2013-12-26 12:30:57 -07:00
|
|
|
val NetDomain = config getString "net.domain"
|
2014-02-01 01:21:18 -07:00
|
|
|
val ActorName = config getString "actor.name"
|
2016-06-10 12:20:56 -06:00
|
|
|
val TimeoutDuration = config duration "timeout.duration"
|
|
|
|
val TimeoutCheckEvery = config duration "timeout.check_every"
|
2013-12-26 12:30:57 -07:00
|
|
|
}
|
|
|
|
import settings._
|
|
|
|
|
2016-06-10 18:13:57 -06:00
|
|
|
val timeout = new ChatTimeout(
|
|
|
|
coll = timeoutColl,
|
2017-02-14 08:34:07 -07:00
|
|
|
duration = TimeoutDuration
|
|
|
|
)
|
2016-06-10 12:20:56 -06:00
|
|
|
|
2016-06-09 15:42:54 -06:00
|
|
|
val api = new ChatApi(
|
2014-01-28 17:42:38 -07:00
|
|
|
coll = chatColl,
|
2016-06-10 18:13:57 -06:00
|
|
|
chatTimeout = timeout,
|
2014-01-28 17:42:38 -07:00
|
|
|
flood = flood,
|
2018-10-14 02:42:08 -06:00
|
|
|
spam = spam,
|
2015-04-25 10:55:54 -06:00
|
|
|
shutup = shutup,
|
2016-06-10 18:22:52 -06:00
|
|
|
modLog = modLog,
|
2017-08-17 16:49:11 -06:00
|
|
|
asyncCache = asyncCache,
|
2016-06-10 12:20:56 -06:00
|
|
|
lilaBus = system.lilaBus,
|
2014-01-28 17:42:38 -07:00
|
|
|
maxLinesPerChat = MaxLinesPerChat,
|
2017-02-14 08:34:07 -07:00
|
|
|
netDomain = NetDomain
|
|
|
|
)
|
2014-01-28 17:42:38 -07:00
|
|
|
|
2017-10-28 15:40:52 -06:00
|
|
|
val panic = new ChatPanic
|
|
|
|
|
2016-06-10 12:20:56 -06:00
|
|
|
system.scheduler.schedule(TimeoutCheckEvery, TimeoutCheckEvery) {
|
2016-06-10 18:13:57 -06:00
|
|
|
timeout.checkExpired foreach api.userChat.reinstate
|
2016-06-10 12:20:56 -06:00
|
|
|
}
|
2016-06-09 15:42:54 -06:00
|
|
|
|
2014-01-28 07:45:28 -07:00
|
|
|
private[chat] lazy val chatColl = db(CollectionChat)
|
2016-06-10 09:15:00 -06:00
|
|
|
private[chat] lazy val timeoutColl = db(CollectionTimeout)
|
2013-12-26 12:30:57 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
object Env {
|
|
|
|
|
2015-08-31 18:36:08 -06:00
|
|
|
lazy val current: Env = "chat" boot new Env(
|
2013-12-26 12:30:57 -07:00
|
|
|
config = lila.common.PlayApp loadConfig "chat",
|
|
|
|
db = lila.db.Env.current,
|
2014-01-31 15:54:34 -07:00
|
|
|
flood = lila.security.Env.current.flood,
|
2018-10-14 02:42:08 -06:00
|
|
|
spam = lila.security.Env.current.spam,
|
2018-12-08 18:11:28 -07:00
|
|
|
shutup = lila.hub.Env.current.shutup,
|
|
|
|
modLog = lila.hub.Env.current.mod,
|
2017-08-17 16:49:11 -06:00
|
|
|
asyncCache = lila.memo.Env.current.asyncCache,
|
2017-09-09 09:01:35 -06:00
|
|
|
system = lila.common.PlayApp.system
|
2017-02-14 08:34:07 -07:00
|
|
|
)
|
2013-12-26 12:30:57 -07:00
|
|
|
}
|