mirror of
https://github.com/minetest/contentdb.git
synced 2024-11-10 09:33:44 +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")
|
flash(gettext("You can't review your own package!"), "danger")
|
||||||
return redirect(package.getURL("packages.view"))
|
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()
|
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)
|
form = ReviewForm(formdata=request.form, obj=review)
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ def review(package):
|
|||||||
form.comment.data = review.thread.replies[0].comment
|
form.comment.data = review.thread.replies[0].comment
|
||||||
|
|
||||||
# Validate and submit
|
# Validate and submit
|
||||||
elif form.validate_on_submit():
|
elif can_review and form.validate_on_submit():
|
||||||
was_new = False
|
was_new = False
|
||||||
if not review:
|
if not review:
|
||||||
was_new = True
|
was_new = True
|
||||||
|
@ -281,12 +281,12 @@ class User(db.Model, UserMixin):
|
|||||||
|
|
||||||
five_mins_ago = datetime.datetime.utcnow() - datetime.timedelta(minutes=5)
|
five_mins_ago = datetime.datetime.utcnow() - datetime.timedelta(minutes=5)
|
||||||
if PackageReview.query.filter_by(author=self) \
|
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
|
return False
|
||||||
|
|
||||||
hour_ago = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
|
hour_ago = datetime.datetime.utcnow() - datetime.timedelta(hours=1)
|
||||||
return PackageReview.query.filter_by(author=self) \
|
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):
|
def __eq__(self, other):
|
||||||
|
Loading…
Reference in New Issue
Block a user