Skip to content

Commit

Permalink
use config's net.rateLimit setting in forum actions (#10734)
Browse files Browse the repository at this point in the history
* switch from god_mode to just use global net.rateLimit setting

to govern rate limits for topic/post creation

* fix typo
  • Loading branch information
schlawg authored Mar 30, 2022
1 parent d3ec96e commit 70581e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/controllers/ForumPost.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import lila.msg.MsgPreset
final class ForumPost(env: Env) extends LilaController(env) with ForumController {

private val CreateRateLimit =
new lila.memo.RateLimit[IpAddress](4, 5.minutes, key = "forum.post")
new lila.memo.RateLimit[IpAddress](
credits = 4,
duration = 5.minutes,
key = "forum.post",
enforce = env.net.rateLimit.value
)

def search(text: String, page: Int) =
OpenBody { implicit ctx =>
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/ForumTopic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import lila.user.Holder
final class ForumTopic(env: Env) extends LilaController(env) with ForumController {

private val CreateRateLimit =
new lila.memo.RateLimit[IpAddress](2, 5.minutes, key = "forum.topic")
new lila.memo.RateLimit[IpAddress](
credits = 2,
duration = 5.minutes,
key = "forum.topic",
enforce = env.net.rateLimit.value
)

def form(categSlug: String) =
Auth { implicit ctx => me =>
Expand Down

0 comments on commit 70581e1

Please sign in to comment.