Partial fix for performance issues with mentions

This commit is contained in:
Michael House 2022-06-07 15:30:27 -05:00
parent e63a021c61
commit 658eacb45d
2 changed files with 17 additions and 9 deletions

View file

@ -1079,6 +1079,8 @@ def remove_follow(username, v):
return {"message": "Follower removed!"}
from urllib.parse import urlparse
@app.get("/pp/<id>")
@app.get("/uid/<id>/pic")
@app.get("/uid/<id>/pic/profile")
@ -1090,10 +1092,22 @@ def user_profile_uid(v, id):
try: id = int(id, 36)
except: abort(404)
x=get_account(id)
return redirect(x.profile_url)
name = f"/pp/{id}"
path = cache.get(name)
tout = 5 * 60 # 5 min
if not path:
user = get_account(id)
path = urlparse(user.profile_url).path
if path.startswith('/assets'):
path = path.lstrip('/')
path = os.path.join(app.root_path, path)
cache.set(name,path,timeout=tout)
return send_file(path)
@app.get("/@<username>/pic")
@cache.cached(timeout=50)
@limiter.exempt
@auth_required
def user_profile_name(v, username):