Skip to content

Commit

Permalink
include url in challenge json
Browse files Browse the repository at this point in the history
  • Loading branch information
RoepStoep committed Apr 6, 2021
1 parent b539c2c commit cea4b6b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions conf/base.conf
Expand Up @@ -545,6 +545,7 @@ challenge {
history.message.ttl = 30 seconds
uid.timeout = 7 seconds
max_playing = ${setup.max_playing}
net.base_url = ${net.base_url}
}
evalCache {
collection.eval_cache = eval_cache
Expand Down
3 changes: 2 additions & 1 deletion modules/challenge/src/main/Env.scala
Expand Up @@ -31,6 +31,7 @@ final class Env(
val UidTimeout = config duration "uid.timeout"
val SocketTimeout = config duration "socket.timeout"
val MaxPlaying = config getInt "max_playing"
val NetBaseUrl = config getString "net.base_url"
}
import settings._

Expand Down Expand Up @@ -79,7 +80,7 @@ final class Env(
maxPerUser = MaxPerUser
)

lazy val jsonView = new JsonView(lightUser, isOnline)
lazy val jsonView = new JsonView(lightUser, isOnline, NetBaseUrl)

scheduler.future(3 seconds, "sweep challenges") {
api.sweep
Expand Down
4 changes: 3 additions & 1 deletion modules/challenge/src/main/JsonView.scala
Expand Up @@ -9,7 +9,8 @@ import lidraughts.socket.UserLagCache

final class JsonView(
getLightUser: lidraughts.common.LightUser.GetterSync,
isOnline: lidraughts.user.User.ID => Boolean
isOnline: lidraughts.user.User.ID => Boolean,
baseUrl: String
) {

import lidraughts.game.JsonView._
Expand All @@ -28,6 +29,7 @@ final class JsonView(

def apply(direction: Option[Direction])(c: Challenge): JsObject = Json.obj(
"id" -> c.id,
"url" -> s"$baseUrl/${c.id}",
"status" -> c.status.name,
"challenger" -> c.challengerUser,
"destUser" -> c.destUser,
Expand Down

0 comments on commit cea4b6b

Please sign in to comment.