![Thibault Duplessis](/assets/img/avatar_default.png)
* 'master' of github.com:ornicar/lila: (639 commits) update todo la "lingua latīna" translation #1738. Author: Anonymous. fa "فارسی" translation #1735. Author: Anonymous. fa "فارسی" translation #1734. Author: Anonymous. pl "polski" translation #1732. Author: Szymon Sawicki. nl "Nederlands, Vlaams" translation #1731. Author: Anonymous. ca "Català" translation #1730. Author: Arbequina. el "Ελληνικά" translation #1729. Author: Γιάννης Ανθυμίδης / Yannis Anthymidis. nl "Nederlands, Vlaams" translation #1728. Author: Anonymous. pl "polski" translation #1723. Author: Anonymous. I'd suggest 'zapis' (= notation) for 'string' instead of 'napis' (= inscription) or 'ciąg' (= sequence)... I corrected also 138 'bookmark this game', 112 'spectator room' and some other minor mistakes. sk "slovenčina" translation #1717. Author: japetko. sv "svenska" translation #1716. Author: Anonymous. update todo list delocalize forum and message internal links la "lingua latīna" translation #1714. Author: Anonymous. ro "Română" translation #1712. Author: Anonymous. la "lingua latīna" translation #1711. Author: 3_1415maldaumen. la "lingua latīna" translation #1710. Author: 3_1415maldaumen. better language selector fix resignation in imported games ... Conflicts: app/analyse/PgnDump.scala app/bookmark/BookmarkApi.scala app/controllers/Analyse.scala app/controllers/LilaController.scala app/controllers/Lobby.scala app/controllers/Monitor.scala app/controllers/Setting.scala app/core/IOFuture.scala app/forum/PostApi.scala app/game/DbGame.scala app/game/Export.scala app/game/GameHelper.scala app/game/GameRepo.scala app/game/PaginatorBuilder.scala app/game/Rewind.scala app/http/Setting.scala app/i18n/Translation.scala app/lobby/Preload.scala app/message/Api.scala app/message/Thread.scala app/mod/ModApi.scala app/round/Finisher.scala app/search/Game.scala app/search/Indexer.scala app/security/AuthImpl.scala app/security/Granter.scala app/security/Store.scala app/setup/FormFactory.scala app/setup/FriendConfig.scala app/setup/Processor.scala app/templating/StringHelper.scala app/tournament/TournamentApi.scala app/user/EloChart.scala app/user/HistoryRepo.scala app/user/UserHelper.scala app/user/UserInfo.scala app/user/UserRepo.scala app/user/WinChart.scala app/views/base/layout.scala.html app/views/user/show.scala.html conf/base.conf conf/routes project/Build.scala public/javascripts/deps.min.js scalachess
107 lines
3.1 KiB
Scala
107 lines
3.1 KiB
Scala
package controllers
|
|
|
|
import lila._
|
|
import http.{ Context, LilaCookie }
|
|
import lobby.Hook
|
|
import views._
|
|
|
|
import play.api.mvc._
|
|
import play.api.libs.json.JsValue
|
|
import play.api.libs.concurrent._
|
|
import play.api.libs.concurrent.Execution.Implicits._
|
|
import play.api.libs.json.Json
|
|
import scala.concurrent.{ Future, Promise }
|
|
import scalaz.effects._
|
|
|
|
object Lobby extends LilaController with Results {
|
|
|
|
private def preloader = env.lobby.preloader
|
|
private def hookRepo = env.lobby.hookRepo
|
|
private def fisherman = env.lobby.fisherman
|
|
private def joiner = env.setup.hookJoiner
|
|
private def forumRecent = env.forum.recent
|
|
private def timelineRecent = env.timeline.entryRepo.recent
|
|
private def messageRepo = env.lobby.messageRepo
|
|
private def featured = env.game.featured
|
|
private def openTours = env.tournament.repo.created
|
|
private def teamCache = env.team.cached
|
|
|
|
val home = Open { implicit ctx ⇒
|
|
Async {
|
|
renderHome(none, Ok).map(_.withHeaders(
|
|
CACHE_CONTROL -> "no-cache",
|
|
PRAGMA -> "no-cache"
|
|
))
|
|
}
|
|
}
|
|
|
|
def handleNotFound(req: RequestHeader): Result = handleNotFound(reqToCtx(req))
|
|
|
|
def handleNotFound(implicit ctx: Context): Result = Async { renderHome(none, NotFound) }
|
|
|
|
private def renderHome[A](myHook: Option[Hook], status: Status)(implicit ctx: Context): Future[Result] =
|
|
preloader(
|
|
auth = ctx.isAuth,
|
|
chat = ctx.canSeeChat,
|
|
myHook = myHook,
|
|
timeline = timelineRecent,
|
|
posts = forumRecent(ctx.me, teamCache.teamIds),
|
|
tours = openTours,
|
|
filter = env.setup.filter
|
|
).map(_.fold(Redirect(_), {
|
|
case (preload, posts, tours, featured) ⇒ status(html.lobby.home(
|
|
Json stringify preload,
|
|
myHook,
|
|
posts,
|
|
tours,
|
|
featured)) |> { response ⇒
|
|
ctx.req.session.data.contains(LilaCookie.sessionId).fold(
|
|
response,
|
|
response withCookies LilaCookie.makeSessionId(ctx.req)
|
|
)
|
|
}
|
|
}))
|
|
|
|
def socket = WebSocket.async[JsValue] { implicit req ⇒
|
|
implicit val ctx = reqToCtx(req)
|
|
env.lobby.socket.join(
|
|
uidOption = get("sri"),
|
|
username = ctx.me map (_.username),
|
|
versionOption = getInt("version"),
|
|
hook = get("hook")
|
|
)
|
|
}
|
|
|
|
def hook(ownerId: String) = Open { implicit ctx ⇒
|
|
Async {
|
|
hookRepo.ownedHook(ownerId).unsafePerformIO.fold(
|
|
Future successful { Redirect(routes.Lobby.home): Result }
|
|
) { hook ⇒ renderHome(hook.some, Ok) }
|
|
}
|
|
}
|
|
|
|
def join(hookId: String) = Open { implicit ctx ⇒
|
|
IORedirect {
|
|
val myHookId = get("cancel")
|
|
joiner(hookId, myHookId)(ctx.me) map { result ⇒
|
|
result.fold(
|
|
_ ⇒ myHookId.fold(routes.Lobby.home)(routes.Lobby.hook(_)),
|
|
pov ⇒ routes.Round.player(pov.fullId))
|
|
}
|
|
}
|
|
}
|
|
|
|
def cancel(ownerId: String) = Open { implicit ctx ⇒
|
|
IORedirect {
|
|
for {
|
|
hook ← hookRepo ownedHook ownerId
|
|
_ ← hook.fold(io())(fisherman.delete)
|
|
} yield routes.Lobby.home
|
|
}
|
|
}
|
|
|
|
val log = Open { implicit ctx ⇒
|
|
IOk(messageRepo.all map { html.lobby.log(_) })
|
|
}
|
|
}
|