Fix ratelimit_user on 3 routes, make proper dec.

remotes/1693176582716663532/tmp_refs/heads/watchparty
Snakes 2022-11-13 07:24:58 -05:00
parent 24678ab7af
commit d3f25739f0
4 changed files with 10 additions and 4 deletions

View File

@ -151,4 +151,10 @@ def ratelimit_user(limit:Union[str, Callable[[], str]]=DEFAULT_RATELIMIT_USER):
Ratelimits based on a user. This requires at least auth_required (or stronger) to be present,
otherwise logged out users will receive 500s
'''
return limiter.limit(limit, key_func=lambda:f'{SITE}-{g.v.id}')
def inner(func):
@functools.wraps(func)
@limiter.limit(limit, key_func=lambda:f'{SITE}-{g.v.id}')
def wrapped(*args, **kwargs):
return func(*args, **kwargs)
return wrapped
return inner

View File

@ -120,10 +120,10 @@ def buy(v, award):
return {"message": f"{award_title} award bought!"}
@app.post("/award/<thing_type>/<id>")
@feature_required('AWARDS')
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
@is_not_permabanned
@ratelimit_user()
@feature_required('AWARDS')
def award_thing(v, thing_type, id):
if thing_type == 'post':
thing = get_post(id)

View File

@ -787,10 +787,10 @@ def settings_title_change(v):
@app.post("/settings/pronouns_change")
@feature_required('PRONOUNS')
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
@auth_required
@ratelimit_user()
@feature_required('PRONOUNS')
def settings_pronouns_change(v):
pronouns = sanitize_settings_text(request.values.get("pronouns"))

View File

@ -319,10 +319,10 @@ def transfer_coins(v, username):
return transfer_currency(v, username, 'coins', True)
@app.post("/@<username>/transfer_bux")
@feature_required('PROCOINS')
@limiter.limit(DEFAULT_RATELIMIT_SLOWER)
@is_not_permabanned
@ratelimit_user()
@feature_required('PROCOINS')
def transfer_bux(v, username):
return transfer_currency(v, username, 'procoins', False)