discard puzzle theme flood
parent
9c1f0cd669
commit
fe3ee253d0
|
@ -106,7 +106,8 @@ final class PuzzleApi(
|
|||
round.themeVote(theme, vote) ?? { newThemes =>
|
||||
import PuzzleRound.{ BSONFields => F }
|
||||
val update =
|
||||
if (newThemes.isEmpty) fuccess($unset(F.themes, F.puzzle).some)
|
||||
if (newThemes.isEmpty || !PuzzleRound.themesLookSane(newThemes))
|
||||
fuccess($unset(F.themes, F.puzzle).some)
|
||||
else
|
||||
vote match {
|
||||
case None =>
|
||||
|
|
|
@ -47,6 +47,10 @@ object PuzzleRound {
|
|||
|
||||
case class Theme(theme: PuzzleTheme.Key, vote: Boolean)
|
||||
|
||||
// max 7 theme upvotes
|
||||
// unlimited downvotes
|
||||
def themesLookSane(themes: List[Theme]): Boolean = themes.count(_.vote) < 8
|
||||
|
||||
object BSONFields {
|
||||
val id = "_id"
|
||||
val win = "w"
|
||||
|
|
Loading…
Reference in New Issue