mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 14:02:24 +01:00
Lower ratelimit
This commit is contained in:
parent
cfd67dce33
commit
dfc0af21ee
@ -54,11 +54,11 @@ def review(package):
|
||||
flash(gettext("You can't review your own package!"), "danger")
|
||||
return redirect(package.getURL("packages.view"))
|
||||
|
||||
if not current_user.canReviewRL():
|
||||
flash(gettext("You've reviewed too many packages recently. Please wait before trying again, and consider making your reviews more detailed"), "danger")
|
||||
return redirect(package.getURL("packages.view"))
|
||||
|
||||
review = PackageReview.query.filter_by(package=package, author=current_user).first()
|
||||
can_review = review is not None or current_user.canReviewRL()
|
||||
|
||||
if not can_review:
|
||||
flash(gettext("You've reviewed too many packages recently. Please wait before trying again, and consider making your reviews more detailed"), "danger")
|
||||
|
||||
form = ReviewForm(formdata=request.form, obj=review)
|
||||
|
||||
@ -69,7 +69,7 @@ def review(package):
|
||||
form.comment.data = review.thread.replies[0].comment
|
||||
|
||||
# Validate and submit
|
||||
elif form.validate_on_submit():
|
||||
elif can_review and form.validate_on_submit():
|
||||
was_new = False
|
||||
if not review:
|
||||
was_new = True
|
||||
|
@ -281,12 +281,12 @@ class User(db.Model, UserMixin):
|
||||
|
||||
five_mins_ago = datetime.datetime.utcnow() - datetime.timedelta(minutes=5)
|
||||
if PackageReview.query.filter_by(author=self) \
|
||||
.filter(PackageReview.created_at > five_mins_ago).count() >= 4 * factor:
|
||||
.filter(PackageReview.created_at > five_mins_ago).count() > 2 * factor:
|
||||
return False
|
||||
|
||||
hour_ago = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
|
||||
return PackageReview.query.filter_by(author=self) \
|
||||
.filter(PackageReview.created_at > hour_ago).count() < 30 * factor
|
||||
.filter(PackageReview.created_at > hour_ago).count() < 10 * factor
|
||||
|
||||
|
||||
def __eq__(self, other):
|
||||
|
Loading…
Reference in New Issue
Block a user