send player.id to mobile app when logged in user matches
This commit is contained in:
parent
6986ed23ff
commit
cc7c34a0ee
|
@ -6,6 +6,7 @@ import chess.format.Forsyth
|
|||
import lila.common.LightUser
|
||||
import lila.common.paginator.Paginator
|
||||
import lila.game.{ Game, PerfPicker }
|
||||
import lila.user.User
|
||||
|
||||
final class UserGameApi(
|
||||
bookmarkApi: lila.bookmark.BookmarkApi,
|
||||
|
@ -18,14 +19,14 @@ final class UserGameApi(
|
|||
def jsPaginator(pag: Paginator[Game])(implicit ctx: Context): Fu[JsObject] =
|
||||
bookmarkApi.filterGameIdsBookmarkedBy(pag.currentPageResults, ctx.me) map { bookmarkedIds =>
|
||||
implicit val gameWriter = Writes[Game] { g =>
|
||||
write(g, bookmarkedIds(g.id))
|
||||
write(g, bookmarkedIds(g.id), ctx.me)
|
||||
}
|
||||
Json.obj(
|
||||
"paginator" -> lila.common.paginator.PaginatorJson(pag)
|
||||
)
|
||||
}
|
||||
|
||||
private def write(g: Game, bookmarked: Boolean) = Json.obj(
|
||||
private def write(g: Game, bookmarked: Boolean, as: Option[User]) = Json.obj(
|
||||
"id" -> g.id,
|
||||
"rated" -> g.rated,
|
||||
"variant" -> g.variant,
|
||||
|
@ -40,7 +41,9 @@ final class UserGameApi(
|
|||
"user" -> p.userId.flatMap(lightUser),
|
||||
"userId" -> p.userId, // for BC
|
||||
"name" -> p.name
|
||||
).add("aiLevel" -> p.aiLevel)
|
||||
)
|
||||
.add("id" -> as.exists(p.isUser).option(p.id))
|
||||
.add("aiLevel" -> p.aiLevel)
|
||||
.add("rating" -> p.rating)
|
||||
.add("ratingDiff" -> p.ratingDiff)
|
||||
}),
|
||||
|
|
Loading…
Reference in a new issue