Skip to content

Commit

Permalink
remove more deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Apr 12, 2024
1 parent 8fc08df commit e2ed347
Show file tree
Hide file tree
Showing 48 changed files with 74 additions and 71 deletions.
2 changes: 1 addition & 1 deletion app/controllers/Challenge.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ final class Challenge(
else
Ok.pageAsync:
c.challengerUserId
.so(env.user.api.withPerf(_, c.perfType))
.so(env.user.api.byIdWithPerf(_, c.perfType))
.map:
html.challenge.theirs(c, json, _, color)
,
Expand Down
11 changes: 6 additions & 5 deletions app/controllers/Insight.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import views.*

import lila.app.{ *, given }
import lila.insight.{ InsightDimension, InsightMetric }
import lila.user.User
import lila.core.i18n.Translate

final class Insight(env: Env) extends LilaController(env):
Expand All @@ -28,7 +27,9 @@ final class Insight(env: Env) extends LilaController(env):
def path(username: UserStr, metric: String, dimension: String, filters: String) = Open:
Accessible(username) { doPath(_, metric, dimension, ~lila.common.String.decodeUriPath(filters)) }

private def doPath(user: User, metric: String, dimension: String, filters: String)(using Context) =
private def doPath(user: lila.user.User, metric: String, dimension: String, filters: String)(using
Context
) =
import lila.insight.InsightApi.UserStatus.*
env.insight.api.userStatus(user).flatMap {
case NoGame => Ok.page(html.site.message.insightNoGames(user))
Expand All @@ -54,7 +55,7 @@ final class Insight(env: Env) extends LilaController(env):
OpenOrScopedBody(parse.json)(): ctx ?=>
AccessibleApi(username) { processQuestion(_, ctx.body) }

private def processQuestion(user: User, body: Request[JsValue])(using Translate) =
private def processQuestion(user: lila.user.User, body: Request[JsValue])(using Translate) =
body.body
.validate[lila.insight.JsonQuestion]
.fold(
Expand All @@ -67,15 +68,15 @@ final class Insight(env: Env) extends LilaController(env):
.map { Ok(_) }
)

private def Accessible(username: UserStr)(f: User => Fu[Result])(using ctx: Context) =
private def Accessible(username: UserStr)(f: lila.user.User => Fu[Result])(using ctx: Context) =
Found(meOrFetch(username)): u =>
env.insight.share
.grant(u)(using ctx.me)
.flatMap:
if _ then f(u)
else Forbidden.page(html.insight.forbidden(u))

private def AccessibleApi(username: UserStr)(f: User => Fu[Result])(using Context) =
private def AccessibleApi(username: UserStr)(f: lila.user.User => Fu[Result])(using Context) =
Found(meOrFetch(username)): u =>
env.insight.share
.grant(u)(using ctx.me)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/Puzzle.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import lila.puzzle.{
}

import lila.rating.PerfType
import lila.user.User

import lila.core.i18n.Translate
import lila.core.user.WithPerf

Expand Down Expand Up @@ -521,7 +521,7 @@ final class Puzzle(env: Env, apiC: => Api) extends LilaController(env):
def help = Open:
Ok.page(html.site.help.puzzle)

private def DashboardPage(username: Option[UserStr])(f: Context ?=> User => Fu[Result]) =
private def DashboardPage(username: Option[UserStr])(f: Context ?=> lila.user.User => Fu[Result]) =
Auth { ctx ?=> me ?=>
meOrFetch(username)
.flatMapz: user =>
Expand Down
2 changes: 1 addition & 1 deletion app/views/account/kid.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import lila.app.ui.ScalatagsTemplate.{ *, given }

object kid:

def apply(u: lila.user.User, form: play.api.data.Form[?], managed: Boolean)(using PageContext) =
def apply(u: User, form: play.api.data.Form[?], managed: Boolean)(using PageContext) =
account.layout(
title = s"${u.username} - ${trans.site.kidMode.txt()}",
active = "kid"
Expand Down
2 changes: 1 addition & 1 deletion app/views/account/pref.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object pref:
private def setting(name: Frag, body: Frag, settingId: String) =
st.section(a(href := "#" + settingId)(h2(id := settingId)(name)), body)

def apply(u: lila.user.User, form: play.api.data.Form[?], categ: lila.pref.PrefCateg)(using PageContext) =
def apply(u: User, form: play.api.data.Form[?], categ: lila.pref.PrefCateg)(using PageContext) =
account.layout(
title = s"${bits.categName(categ)} - ${u.username} - ${preferences.txt()}",
active = categ.slug
Expand Down
2 changes: 1 addition & 1 deletion app/views/account/profile.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object profile:
trans.site.oneUrlPerLine()
)

def apply(u: lila.user.User, form: play.api.data.Form[?])(using ctx: PageContext) =
def apply(u: User, form: play.api.data.Form[?])(using ctx: PageContext) =
account.layout(
title = s"${u.username} - ${trans.site.editProfile.txt()}",
active = "editProfile"
Expand Down
2 changes: 1 addition & 1 deletion app/views/account/security.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import lila.app.ui.ScalatagsTemplate.{ *, given }
object security:

def apply(
u: lila.user.User,
u: User,
sessions: List[lila.security.LocatedSession],
curSessionId: String,
clients: List[lila.oauth.AccessTokenApi.Client],
Expand Down
2 changes: 1 addition & 1 deletion app/views/account/username.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import lila.app.ui.ScalatagsTemplate.{ *, given }

object username:

def apply(u: lila.user.User, form: play.api.data.Form[?])(using PageContext) =
def apply(u: User, form: play.api.data.Form[?])(using PageContext) =
account.layout(
title = s"${u.username} - ${trans.site.editProfile.txt()}",
active = "username"
Expand Down
2 changes: 1 addition & 1 deletion app/views/analyse/replay.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ object replay:
analysisStarted: Boolean,
simul: Option[lila.simul.Simul],
cross: Option[lila.game.Crosstable.WithMatchup],
userTv: Option[lila.user.User],
userTv: Option[User],
chatOption: Option[lila.chat.UserChat.Mine],
bookmarked: Boolean
)(using ctx: PageContext) =
Expand Down
2 changes: 1 addition & 1 deletion app/views/base/layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ object layout:
.txt()}</a>
</div>"""

private def dasher(me: lila.user.User) =
private def dasher(me: User) =
div(cls := "dasher")(
a(id := "user_tag", cls := "toggle link", href := routes.Auth.logoutGet)(me.username),
div(id := "dasher_app", cls := "dropdown")
Expand Down
2 changes: 1 addition & 1 deletion app/views/clas/studentDashboard.scala
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ object studentDashboard:
}
)

private def challengeTd(user: lila.user.User)(using ctx: PageContext) =
private def challengeTd(user: User)(using ctx: PageContext) =
if ctx.is(user) then td
else
val online = isOnline(user.id)
Expand Down
2 changes: 1 addition & 1 deletion app/views/game/bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ object bits:
tour: Option[lila.tournament.TourAndTeamVs],
cross: Option[lila.game.Crosstable.WithMatchup],
simul: Option[lila.simul.Simul],
userTv: Option[lila.user.User] = None,
userTv: Option[User] = None,
bookmarked: Boolean
)(using ctx: Context) =
div(
Expand Down
4 changes: 2 additions & 2 deletions app/views/game/side.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ object side:
initialFen: Option[chess.format.Fen.Full],
tour: Option[lila.tournament.TourAndTeamVs],
simul: Option[lila.simul.Simul],
userTv: Option[lila.user.User] = None,
userTv: Option[User] = None,
bookmarked: Boolean
)(using ctx: Context): Option[Frag] =
ctx.noBlind.option(
Expand All @@ -32,7 +32,7 @@ object side:
initialFen: Option[chess.format.Fen.Full],
tour: Option[lila.tournament.TourAndTeamVs],
simul: Option[lila.simul.Simul],
userTv: Option[lila.user.User] = None,
userTv: Option[User] = None,
bookmarked: Boolean
)(using ctx: Context): Option[Frag] =
ctx.noBlind.option {
Expand Down
2 changes: 1 addition & 1 deletion app/views/game/widgets.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object widgets:
def apply(
games: Seq[Game],
notes: Map[GameId, String] = Map(),
user: Option[lila.user.User] = None,
user: Option[User] = None,
ownerLink: Boolean = false
)(using Context): Frag =
games.map { g =>
Expand Down
2 changes: 1 addition & 1 deletion app/views/mod/impersonate.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import lila.app.ui.ScalatagsTemplate.{ *, given }

object impersonate:

def apply(user: lila.user.User)(using Translate) =
def apply(user: User)(using Translate) =
div(id := "impersonate")(
div(cls := "meat")(
"You are impersonating ",
Expand Down
2 changes: 1 addition & 1 deletion app/views/mod/table.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ object table:

private val dataSort = attr("data-sort")

def apply(users: List[lila.user.User])(using PageContext) =
def apply(users: List[User])(using PageContext) =

val title = "All mods"

Expand Down
2 changes: 1 addition & 1 deletion app/views/oAuth/token/create.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import lila.core.i18n.I18nKey.oauthScope as ot

object create:

def apply(form: Form[lila.oauth.OAuthTokenForm.Data], me: lila.user.User)(using PageContext) =
def apply(form: Form[lila.oauth.OAuthTokenForm.Data], me: User)(using PageContext) =

val title = ot.newAccessToken

Expand Down
2 changes: 1 addition & 1 deletion app/views/plan/indexPayPal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ object indexPayPal:
private val dataForm = attr("data-form")

def apply(
me: lila.user.User,
me: User,
patron: lila.plan.Patron,
subscription: lila.plan.PayPalSubscription,
gifts: List[lila.plan.Charge.Gift]
Expand Down
2 changes: 1 addition & 1 deletion app/views/plan/indexStripe.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object indexStripe:
private val dataForm = attr("data-form")

def apply(
me: lila.user.User,
me: User,
patron: lila.plan.Patron,
info: lila.plan.CustomerInfo.Monthly,
stripePublicKey: String,
Expand Down
2 changes: 1 addition & 1 deletion app/views/round/bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ object bits:
data: play.api.libs.json.JsObject,
tour: Option[lila.tournament.TourAndTeamVs],
simul: Option[lila.simul.Simul],
userTv: Option[lila.user.User] = None,
userTv: Option[User] = None,
bookmarked: Boolean
)(using Context) =
views.html.game.side(
Expand Down
2 changes: 1 addition & 1 deletion app/views/round/watcher.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object watcher:
tour: Option[lila.tournament.TourAndTeamVs],
simul: Option[lila.simul.Simul],
cross: Option[lila.game.Crosstable.WithMatchup],
userTv: Option[lila.user.User] = None,
userTv: Option[User] = None,
chatOption: Option[lila.chat.UserChat.Mine],
bookmarked: Boolean
)(using ctx: PageContext) =
Expand Down
2 changes: 1 addition & 1 deletion app/views/tutor/bits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object bits:
def percentNumber[A](v: A)(using number: TutorNumber[A]) = f"${number.double(v)}%1.1f"
def percentFrag[A](v: A)(using TutorNumber[A]) = frag(strong(percentNumber(v)), "%")

private[tutor] def otherUser(user: lila.user.User)(using ctx: Context) =
private[tutor] def otherUser(user: User)(using ctx: Context) =
ctx.isnt(user).option(userSpan(user, withOnline = false))

private[tutor] def layout(
Expand Down
2 changes: 1 addition & 1 deletion app/views/tutor/opening.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object opening:
perfReport: TutorPerfReport,
report: TutorOpeningFamily,
as: chess.Color,
user: lila.user.User,
user: User,
puzzle: Option[lila.puzzle.PuzzleOpening.FamilyWithCount]
)(using PageContext) =
bits.layout(
Expand Down
2 changes: 1 addition & 1 deletion app/views/tutor/openings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import lila.tutor.TutorPerfReport

object openings:

def apply(report: TutorPerfReport, user: lila.user.User)(using ctx: PageContext) =
def apply(report: TutorPerfReport, user: User)(using ctx: PageContext) =
bits.layout(menu = perf.menu(user, report, "openings"))(
cls := "tutor__openings box",
boxTop(
Expand Down
2 changes: 1 addition & 1 deletion app/views/tutor/phases.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import lila.tutor.TutorPerfReport

object phases:

def apply(report: TutorPerfReport, user: lila.user.User)(using PageContext) =
def apply(report: TutorPerfReport, user: User)(using PageContext) =
bits.layout(menu = perf.menu(user, report, "phases"))(
cls := "tutor__phases box",
boxTop(
Expand Down
2 changes: 1 addition & 1 deletion app/views/tutor/skills.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import lila.tutor.TutorPerfReport

object skills:

def apply(report: TutorPerfReport, user: lila.user.User)(using PageContext) =
def apply(report: TutorPerfReport, user: User)(using PageContext) =
bits.layout(menu = perf.menu(user, report, "skills"))(
cls := "tutor__skills box",
boxTop(
Expand Down
2 changes: 1 addition & 1 deletion app/views/tutor/time.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import lila.tutor.TutorPerfReport

object time:

def apply(report: TutorPerfReport, user: lila.user.User)(using PageContext) =
def apply(report: TutorPerfReport, user: User)(using PageContext) =
bits.layout(menu = perf.menu(user, report, "time"))(
cls := "tutor__time box",
boxTop(
Expand Down
2 changes: 1 addition & 1 deletion app/views/user/download.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import lila.app.ui.ScalatagsTemplate.{ *, given }
import lila.rating.PerfType

object download:
def apply(user: lila.user.User)(using ctx: PageContext): Frag =
def apply(user: User)(using ctx: PageContext): Frag =
views.html.base.layout(
title = s"${user.username}${trans.site.exportGames.txt()}",
moreCss = cssTag("search"),
Expand Down
8 changes: 4 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ lazy val game = module("game",
)

lazy val gameSearch = module("gameSearch",
Seq(game, user, search),
Seq(game, search),
reactivemongo.bundle
)

lazy val tv = module("tv",
Seq(game, user),
Seq(game),
Seq(hasher) ++ reactivemongo.bundle
)

Expand All @@ -250,7 +250,7 @@ lazy val round = module("round",
)

lazy val pool = module("pool",
Seq(game, user),
Seq(game),
reactivemongo.bundle
)

Expand All @@ -265,7 +265,7 @@ lazy val lobby = module("lobby",
)

lazy val setup = module("setup",
Seq(lobby, user),
Seq(lobby),
reactivemongo.bundle
)

Expand Down
2 changes: 1 addition & 1 deletion modules/challenge/src/main/ChallengeJoiner.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final private class ChallengeJoiner(
if _ then fuccess(Left("The challenge has already been accepted"))
else
c.challengerUserId
.so(userApi.withPerf(_, c.perfType))
.so(userApi.byIdWithPerf(_, c.perfType))
.flatMap: origUser =>
val game = ChallengeJoiner.createGame(c, origUser, destUser)
gameRepo
Expand Down
4 changes: 2 additions & 2 deletions modules/challenge/src/main/ChallengeMaker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ final class ChallengeMaker(
.opponentOf(dest)
.so: challenger =>
for
orig <- challenger.userId.so(userApi.withPerf(_, game.perfType))
orig <- challenger.userId.so(userApi.byIdWithPerf(_, game.perfType))
dest <- perfsRepo.withPerf(dest, game.perfType)
yield Data(game, challenger, orig, dest).some

private[challenge] def makeRematchOf(game: Game, challenger: User): Fu[Option[Challenge]] =
Pov(game, challenger.id).so: pov =>
pov.opponent.userId.so(userApi.withPerf(_, game.perfType)).flatMapz { dest =>
pov.opponent.userId.so(userApi.byIdWithPerf(_, game.perfType)).flatMapz { dest =>
for
challenger <- perfsRepo.withPerf(challenger, game.perfType)
rematch <- makeRematch(pov, challenger.some, dest)
Expand Down
2 changes: 1 addition & 1 deletion modules/challenge/src/main/ChallengeRepo.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final private class ChallengeRepo(colls: ChallengeColls)(using

def byId(id: Challenge.Id) = coll.find($id(id)).one[Challenge]

def byIdFor(id: Challenge.Id, dest: lila.user.User) =
def byIdFor(id: Challenge.Id, dest: User) =
coll.find($id(id) ++ $doc("destUser.id" -> dest.id)).one[Challenge]

def exists(id: Challenge.Id) = coll.countSel($id(id)).dmap(0 <)
Expand Down
Loading

0 comments on commit e2ed347

Please sign in to comment.