cache profile pics for 1 day to prevent DDOS

master
Aevann1 2022-06-17 21:21:26 +02:00
parent 30ed6daa26
commit e072e15819
1 changed files with 4 additions and 7 deletions

View File

@ -1185,12 +1185,9 @@ def remove_follow(username, v):
@app.get("/logged_out/pp/<id>")
@app.get("/logged_out/uid/<id>/pic")
@app.get("/logged_out/uid/<id>/pic/profile")
@cache.memoize(timeout=86400)
@limiter.exempt
@auth_desired
def user_profile_uid(v, id):
if not v and not request.path.startswith('/logged_out'): return redirect(f"/logged_out{request.full_path}")
if v and request.path.startswith('/logged_out'): return redirect(request.full_path.replace('/logged_out',''))
def user_profile_uid(id):
try: id = int(id)
except:
try: id = int(id, 36)
@ -1200,9 +1197,9 @@ def user_profile_uid(v, id):
return redirect(x.profile_url)
@app.get("/@<username>/pic")
@cache.memoize(timeout=86400)
@limiter.exempt
@auth_required
def user_profile_name(v, username):
def user_profile_name(username):
x = get_user(username)
return redirect(x.profile_url)