fix favorite opponents view as anon

This commit is contained in:
Thibault Duplessis 2014-05-21 20:56:50 +02:00
parent ed723d4458
commit 1f70ca62ab

View file

@ -151,15 +151,18 @@ object User extends LilaController {
def opponents(username: String) = Open { implicit ctx =>
OptionFuOk(UserRepo named username) { user =>
lila.game.BestOpponents(user.id, 50) flatMap { ops =>
(ctx.isAuth ?? { Env.pref.api.followables(ops map (_._1.id)) }) flatMap { followables =>
(ops zip followables).map {
case ((u, nb), followable) => ctx.userId ?? { myId =>
relationApi.relation(myId, u.id)
} map { lila.relation.Related(u, nb, followable, _) }
}.sequenceFu map { relateds =>
html.user.opponents(user, relateds)
ctx.isAuth.fold(
Env.pref.api.followables(ops map (_._1.id)),
fuccess(List.fill(50)(true))
) flatMap { followables =>
(ops zip followables).map {
case ((u, nb), followable) => ctx.userId ?? { myId =>
relationApi.relation(myId, u.id)
} map { lila.relation.Related(u, nb, followable, _) }
}.sequenceFu map { relateds =>
html.user.opponents(user, relateds)
}
}
}
}
}
}