add /tv/channels API endpoint
parent
e79409db2f
commit
784e8257a2
|
@ -28,6 +28,14 @@ object Tv extends LilaController {
|
|||
}
|
||||
}
|
||||
|
||||
def channels = Action.async {
|
||||
import play.api.libs.json._
|
||||
implicit val championWrites = Json.writes[lila.tv.Tv.Champion]
|
||||
Env.tv.tv.getChampions map {
|
||||
_.channels map { case (chan, champ) => chan.name -> champ }
|
||||
} map { Json.toJson(_) } map { Ok(_) }
|
||||
}
|
||||
|
||||
private def lichessTv(channel: lila.tv.Tv.Channel)(implicit ctx: Context) =
|
||||
OptionFuResult(Env.tv.tv getGameAndHistory channel) {
|
||||
case (game, history) =>
|
||||
|
|
|
@ -23,6 +23,7 @@ GET /tv controllers.Tv.index
|
|||
GET /tv/embed controllers.Tv.embed
|
||||
GET /tv/frame controllers.Tv.frame
|
||||
GET /tv/feed controllers.Tv.feed
|
||||
GET /tv/channels controllers.Tv.channels
|
||||
GET /tv/:chanKey controllers.Tv.onChannel(chanKey: String)
|
||||
GET /tv/:chanKey/$gameId<\w{8}>/$color<white|black>/sides controllers.Tv.sides(chanKey: String, gameId: String, color: String)
|
||||
GET /games controllers.Tv.games
|
||||
|
|
|
@ -52,7 +52,7 @@ object Tv {
|
|||
import chess.{ Speed => S, variant => V }
|
||||
import lila.rating.{ PerfType => P }
|
||||
|
||||
case class Champion(user: LightUser, rating: Int)
|
||||
case class Champion(user: LightUser, rating: Int, gameId: Game.ID)
|
||||
case class Champions(channels: Map[Channel, Champion]) {
|
||||
def get = channels.get _
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ private[tv] final class TvActor(
|
|||
val player = game.firstPlayer
|
||||
val user = player.userId flatMap lightUser
|
||||
(user |@| player.rating) apply {
|
||||
case (u, r) => channelChampions += (channel -> Tv.Champion(u, r))
|
||||
case (u, r) => channelChampions += (channel -> Tv.Champion(u, r, game.id))
|
||||
}
|
||||
selectChannel ! lila.socket.Channel.Publish(makeMessage("tvSelect", Json.obj(
|
||||
"channel" -> channel.key,
|
||||
|
|
Loading…
Reference in New Issue