From a0c129b8a0874e7051b05467c3f9a1ee7c366758 Mon Sep 17 00:00:00 2001 From: Christopher Slowe Date: Thu, 9 Jul 2009 22:08:43 -0700 Subject: [PATCH] fix comment rate limiter. --- r2/r2/controllers/api.py | 7 ++++--- r2/r2/templates/usertext.html | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 26e67fcfc..9c53b8f47 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -596,11 +596,12 @@ class ApiController(RedditController): #remove the ratelimit error if the user's karma is high if not should_ratelimit: - c.errors.remove(errors.RATELIMIT) + c.errors.remove((errors.RATELIMIT, 'ratelimit')) if (not commentform.has_errors("text", errors.NO_TEXT, - errors.TOO_LONG, + errors.TOO_LONG) and + not commentform.has_errors("ratelimit", errors.RATELIMIT) and not commentform.has_errors("parent", errors.DELETED_COMMENT)): @@ -676,7 +677,7 @@ class ApiController(RedditController): sr = thing.subreddit_slow should_ratelimit = sr.should_ratelimit(c.user, 'link') if not should_ratelimit: - c.errors.remove(errors.RATELIMIT) + c.errors.remove((errors.RATELIMIT, 'ratelimit')) # share_from and messages share a too_long error. # finding an error on one necessitates hiding the other error diff --git a/r2/r2/templates/usertext.html b/r2/r2/templates/usertext.html index 9419d750f..1eab4fb5a 100644 --- a/r2/r2/templates/usertext.html +++ b/r2/r2/templates/usertext.html @@ -70,6 +70,7 @@ style = "" if thing.creating else "display: none")} ${error_field("TOO_LONG", "text", "span")} + ${error_field("RATELIMIT", "ratelimit", "span")} ${error_field("NO_TEXT", "text", "span")}