Skip to content

Commit

Permalink
Merge branch 'master' into modGamesDownloadPgn
Browse files Browse the repository at this point in the history
* master: (24 commits)
  only show inputs of analysable games
  add links to the forum etiquette - closes lichess-org/tavern#41
  show boost inquiry games on the mod games view
  filter mod games view by opponents
  return to team kick form after submit - closes #8294
  add chessground workaround in ui/learn css - closes #8286
  only show patron data to full admins - closes lichess-org/tavern#34
  filter reports a mod can see in the "all" room
  moderator report room access - closes lichess-org/tavern#42
  fix chat timeout message
  automatically renew twitch API token
  remove forum categ sort by pos
  remove forum Categ.pos
  remove onesignal push
  Fix disabled rematch button
  Glicko-2 converges within 1000 iterations or something is wrong
  Ratings - account for first player advantage #6818
  ceval: Avoid large MAXIMUM_MEMORY if it cannot grow anyway
  update stockfish-mv.wasm for atomic king explosion (fixes #8275 again)
  make it scrollable
  ...
  • Loading branch information
ornicar committed Mar 2, 2021
2 parents cc40b0c + fccd9b5 commit 741f007
Show file tree
Hide file tree
Showing 42 changed files with 369 additions and 298 deletions.
2 changes: 1 addition & 1 deletion COPYING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Lichess as deployed on https://lichess.org/ also uses these external services:
- [check.torproject.org](https://check.torproject.org/exit-addresses) for a list or Tor exit nodes
- [detectlanguage.com](https://detectlanguage.com/)
- Fallback to [Google Fonts](https://fonts.google.com/)
- [Google Cloud Messaging](https://developers.google.com/cloud-messaging/) and [OneSignal](https://onesignal.com/) for mobile notifications
- [Google Cloud Messaging](https://developers.google.com/cloud-messaging/) for mobile notifications
- [reCAPTCHA](https://www.google.com/recaptcha/)
- [PeerJS](https://peerjs.com/) for voice chat
- [crowdin](https://crowdin.com/project/lichess) for localization
1 change: 0 additions & 1 deletion app/controllers/Dev.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ final class Dev(env: Env) extends LilaController(env) {
env.report.discordScoreThresholdSetting,
env.streamer.homepageMaxSetting,
env.streamer.alwaysFeaturedSetting,
env.streamer.twitchCredentialsSetting,
env.rating.ratingFactorsSetting,
env.plan.donationGoalSetting,
env.apiTimelineSetting,
Expand Down
27 changes: 22 additions & 5 deletions app/controllers/GameMod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,38 @@ final class GameMod(env: Env) extends LilaController(env) {

object GameMod {

case class Filter(arena: Option[String], swiss: Option[String])
case class Filter(arena: Option[String], swiss: Option[String], opponents: Option[String]) {
def opponentIds: List[lila.user.User.ID] =
(~opponents)
.take(800)
.replace(",", " ")
.split(' ')
.view
.flatMap(_.trim.some.filter(_.nonEmpty))
.filter(lila.user.User.couldBeUsername)
.map(lila.user.User.normalize)
.toList
.distinct
}

val emptyFilter = Filter(none, none)
val emptyFilter = Filter(none, none, none)

def toDbSelect(filter: Filter): Bdoc = filter.arena.?? { id =>
$doc(lila.game.Game.BSONFields.tournamentId -> id)
} ++ filter.swiss.?? { id =>
$doc(lila.game.Game.BSONFields.swissId -> id)
}
} ++ (filter.opponentIds match {
case Nil => $empty
case List(id) => $and(lila.game.Game.BSONFields.playerUids $eq id)
case ids => $and(lila.game.Game.BSONFields.playerUids $in ids)
})

val filterForm =
Form(
mapping(
"arena" -> optional(nonEmptyText),
"swiss" -> optional(nonEmptyText)
"arena" -> optional(nonEmptyText),
"swiss" -> optional(nonEmptyText),
"opponents" -> optional(nonEmptyText)
)(Filter.apply)(Filter.unapply _)
)

Expand Down
18 changes: 14 additions & 4 deletions app/controllers/Report.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,33 @@ final class Report(
Secure(_.SeeReport) { implicit ctx => me =>
if (env.streamer.liveStreamApi.isStreaming(me.id) && !getBool("force"))
fuccess(Forbidden(html.site.message.streamingMod))
else renderList(env.report.modFilters.get(me).fold("all")(_.key))
else renderList(me, env.report.modFilters.get(me).fold("all")(_.key))
}

def listWithFilter(room: String) =
Secure(_.SeeReport) { implicit ctx => me =>
env.report.modFilters.set(me, Room(room))
renderList(room)
if (Room(room).fold(true)(Room.isGrantedFor(me))) renderList(me, room)
else notFound
}

protected[controllers] def getScores =
api.maxScores zip env.streamer.api.approval.countRequests zip env.appeal.api.countUnread

private def renderList(room: String)(implicit ctx: Context) =
private def renderList(me: UserModel, room: String)(implicit ctx: Context) =
api.openAndRecentWithFilter(12, Room(room)) zip
getScores flatMap { case (reports, scores ~ streamers ~ appeals) =>
(env.user.lightUserApi preloadMany reports.flatMap(_.report.userIds)) inject
Ok(html.report.list(reports, room, scores, streamers, appeals))
Ok(
html.report
.list(
reports.filter(r => lila.report.Reason.isGrantedFor(me)(r.report.reason)),
room,
scores,
streamers,
appeals
)
)
}

def inquiry(id: String) =
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Team.scala
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ final class Team(
WithOwnedTeam(id) { team =>
implicit val req = ctx.body
forms.selectMember.bindFromRequest().value ?? { api.kick(team, _, me) } inject Redirect(
routes.Team.show(team.id)
routes.Team.kickForm(team.id)
).flashSuccess
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ final class User(
appeal <- isGranted(_.Appeals) ?? env.appeal.api.get(user)
} yield view.modLog(history, appeal)

val plan = env.plan.api.recentChargesOf(user).map(view.plan).dmap(~_)
val plan = isGranted(_.Admin) ?? env.plan.api.recentChargesOf(user).map(view.plan).dmap(~_)

val student = env.clas.api.student.findManaged(user).map2(view.student).dmap(~_)

Expand Down
12 changes: 11 additions & 1 deletion app/views/forum/topic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ object topic {
trans.toRequestSupport(
strong(a(href := routes.Main.contact)(trans.tryTheContactPage()))
)
),
p(
"Make sure to read ",
strong(a(href := routes.Page.loneBookmark("forum-etiquette"))("the forum etiquette"))
)
),
postForm(cls := "form3", action := routes.ForumTopic.create(categ.slug))(
Expand Down Expand Up @@ -171,7 +175,13 @@ object topic {
action := s"${routes.ForumPost.create(categ.slug, topic.slug, posts.currentPage)}#reply",
novalidate
)(
form3.group(form("text"), trans.message()) { f =>
form3.group(
form("text"),
trans.message(),
help = a(dataIcon := "", cls := "text", href := routes.Page.loneBookmark("forum-etiquette"))(
"Forum etiquette"
).some
) { f =>
form3.textarea(f, klass = "post-text-area")(rows := 10, bits.dataTopic := topic.id)
},
views.html.base.captcha(form, captcha),
Expand Down
13 changes: 10 additions & 3 deletions app/views/mod/games.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ object games {
h1(userLink(user), " games (WIP)"),
div(cls := "box__top__actions")(
form(method := "get", action := routes.GameMod.index(user.id), cls := "mod-games__filter-form")(
form3.input(filterForm("opponents"))(placeholder := "Opponents"),
form3.select(
filterForm("arena"),
arenas.map(t =>
Expand Down Expand Up @@ -74,7 +75,13 @@ object games {
table(cls := "mod-games game-list slist")(
thead(
tr(
sortNoneTh(input(tpe := "checkbox", name := s"game[]", st.value := "all")),
sortNoneTh(
input(
tpe := "checkbox",
name := s"game[]",
st.value := "all"
)
),
sortNumberTh("Opponent"),
sortNumberTh("Speed"),
th(iconTag('g')),
Expand All @@ -89,8 +96,8 @@ object games {
tbody(
games.map { case (pov, assessment) =>
tr(
td(
input(
td(cls := pov.game.analysable.option("input"))(
pov.game.analysable option input(
tpe := "checkbox",
name := s"game[]",
st.value := pov.gameId
Expand Down
44 changes: 29 additions & 15 deletions app/views/mod/inquiry.scala
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package views.html.mod

import cats.data.NonEmptyList
import controllers.routes
import scala.util.matching.Regex

import lila.api.Context
import lila.app.templating.Environment._
import lila.app.ui.ScalatagsTemplate._
import lila.common.String.html.richText

import controllers.routes
import lila.report.Reason
import lila.report.Report
import lila.user.User

object inquiry {

Expand Down Expand Up @@ -124,19 +127,13 @@ object inquiry {
)
),
div(cls := "links")(
in.report.boostWith
.map { userId =>
a(href := s"${routes.User.games(in.user.id, "search")}?players.b=$userId")("View", br, "Games")
}
.getOrElse {
in.report.bestAtomByHuman.map { atom =>
a(href := s"${routes.User.games(in.user.id, "search")}?players.b=${atom.by.value}")(
"View",
br,
"Games"
)
}
},
boostOpponents(in.report) map { opponents =>
a(href := s"${routes.GameMod.index(in.user.id)}?opponents=${opponents.toList mkString ", "}")(
"View",
br,
"Games"
)
},
isGranted(_.Shadowban) option
a(href := routes.Mod.communicationPublic(in.user.id))("View", br, "Comms")
),
Expand Down Expand Up @@ -236,6 +233,23 @@ object inquiry {
)
}

private def boostOpponents(report: Report): Option[NonEmptyList[User.ID]] =
(report.reason == Reason.Boost) ?? {
report.atoms.toList
.withFilter(_.byLichess)
.flatMap(_.text.linesIterator)
.collect {
case farmWithRegex(userId) => userId
case sandbagWithRegex(userId) => userId
}
.toNel
}

private val farmWithRegex =
("^Boosting: farms rating points from @(" + User.historicalUsernameRegex.pattern + ")").r.unanchored
private val sandbagWithRegex =
("^Sandbagging: throws games to @(" + User.historicalUsernameRegex.pattern + ")").r.unanchored

private def thenForms(url: String, button: Tag) =
div(
postForm(
Expand Down
22 changes: 12 additions & 10 deletions app/views/report/list.scala
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,19 @@ object list {
"All",
scoreTag(scores.highest)
),
lila.report.Room.all.map { room =>
a(
href := routes.Report.listWithFilter(room.key),
cls := List(
"active" -> (filter == room.key),
s"room-${room.key}" -> true
ctx.me ?? { me =>
lila.report.Room.all.filter(lila.report.Room.isGrantedFor(me)).map { room =>
a(
href := routes.Report.listWithFilter(room.key),
cls := List(
"active" -> (filter == room.key),
s"room-${room.key}" -> true
)
)(
room.name,
scoreTag(scores get room)
)
)(
room.name,
scoreTag(scores get room)
)
}
},
(appeals > 0 && isGranted(_.Appeals)) option a(
href := routes.Appeal.queue,
Expand Down
9 changes: 4 additions & 5 deletions conf/base.conf
Original file line number Diff line number Diff line change
Expand Up @@ -256,11 +256,6 @@ push {
vapid_public_key = "BGr5CL0QlEYa7qW7HLqe7DFkCeTsYMLsi1Db+5Vwt1QBIs6+WxN8066AjtP8S9u+w+CbleE8xWY+qQaNEMs7sAs="
url = "http://push.lichess.ovh:9054"
}
onesignal {
url = "https://onesignal.com/api/v1/notifications"
app_id = ""
key = ""
}
firebase {
url = "https://fcm.googleapis.com/v1/projects/lichess-1366/messages:send"
json = ""
Expand Down Expand Up @@ -322,6 +317,10 @@ streamer {
collection.streamer = "streamer"
paginator.max_per_page = 12
streaming {
twitch {
client_id = ""
secret = ""
}
google.api_key = ""
keyword = "lichess.org"
}
Expand Down
2 changes: 1 addition & 1 deletion modules/chat/src/main/ChatApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ final class ChatApi(
val line = c.hasRecentLine(user) option UserLine(
username = systemUserId,
title = None,
text = s"${user.username} was timed out 10 minutes for ${reason.name}.",
text = s"${user.username} was timed out 15 minutes for ${reason.name}.",
troll = false,
deleted = false
)
Expand Down
1 change: 0 additions & 1 deletion modules/forum/src/main/Categ.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ case class Categ(
_id: String, // slug
name: String,
desc: String,
pos: Int,
team: Option[TeamID] = None,
nbTopics: Int,
nbPosts: Int,
Expand Down
Loading

0 comments on commit 741f007

Please sign in to comment.