fix api url generation

This commit is contained in:
Thibault Duplessis 2012-06-12 12:51:58 +02:00
parent 978a8154f7
commit 3530158d2e
2 changed files with 6 additions and 8 deletions

View file

@ -15,12 +15,10 @@ final class Messenger(
i18nKeys: I18nKeys) {
def init(game: DbGame): IO[List[Event]] =
systemMessages(game, initKeys(game))
private def initKeys(game: DbGame): List[SelectI18nKey] = List(
game.creatorColor.fold(_.whiteCreatesTheGame, _.blackCreatesTheGame),
game.invitedColor.fold(_.whiteJoinsTheGame, _.blackJoinsTheGame)
)
systemMessages(game, List(
game.creatorColor.fold(_.whiteCreatesTheGame, _.blackCreatesTheGame),
game.invitedColor.fold(_.whiteJoinsTheGame, _.blackJoinsTheGame)
))
def playerMessage(ref: PovRef, text: String): IO[List[Event]] =
cleanupText(text).fold(

View file

@ -7,6 +7,7 @@ import user.User
import chess.{ Game, Board, Color => ChessColor }
import ai.Ai
import lobby.{ Hook, Fisherman }
import i18n.I18nDomain
import controllers.routes
import scalaz.effects._
@ -66,8 +67,7 @@ final class Processor(
} yield hook
def api(implicit ctx: Context): IO[Map[String, Any]] = {
val domainRegex = """^.+([^\.]+\.[^\.]+)$""".r
val domain = "http://" + domainRegex.replaceAllIn(ctx.req.domain, _ group 1)
val domain = "http://" + I18nDomain(ctx.req.domain).commonDomain
val config = ApiConfig
val pov = config.pov
val game = ctx.me.fold(