forked from rDrama/rDrama
1
0
Fork 0

remove the .json endpoints

master
Aevann 2023-03-03 03:53:04 +02:00
parent bffd125cde
commit 01f671d19a
1 changed files with 10 additions and 14 deletions

View File

@ -798,7 +798,6 @@ def userpagelisting(user:User, site=None, v=None, page:int=1, sort="new", t="all
return [x[0] for x in posts]
@app.get("/@<username>")
@app.get("/@<username>.json")
@limiter.limit(DEFAULT_RATELIMIT)
@auth_desired_with_logingate
def u_username_wall(v:Optional[User], username:str):
@ -807,7 +806,7 @@ def u_username_wall(v:Optional[User], username:str):
return redirect(f"/@{u.username}")
if v and hasattr(u, 'is_blocking') and u.is_blocking:
if g.is_api_or_xhr or request.path.endswith(".json"):
if g.is_api_or_xhr:
abort(403, f"You are blocking @{u.username}.")
return render_template("userpage/blocking.html", u=u, v=v), 403
@ -845,14 +844,13 @@ def u_username_wall(v:Optional[User], username:str):
next_exists = (len(comments) > PAGE_SIZE)
comments = comments[:PAGE_SIZE]
if (v and v.client) or request.path.endswith(".json"):
if v and v.client:
return {"data": [c.json(g.db) for c in comments]}
return render_template("userpage/wall.html", u=u, v=v, listing=comments, page=page, next_exists=next_exists, is_following=is_following, standalone=True, render_replies=True, wall=True)
@app.get("/@<username>/wall/comment/<int:cid>")
@app.get("/@<username>/wall/comment/<int:cid>.json")
@limiter.limit(DEFAULT_RATELIMIT)
@auth_desired_with_logingate
def u_username_wall_comment(v:User, username:str, cid):
@ -863,7 +861,7 @@ def u_username_wall_comment(v:User, username:str, cid):
u = comment.wall_user
if v and hasattr(u, 'is_blocking') and u.is_blocking:
if g.is_api_or_xhr or request.path.endswith(".json"):
if g.is_api_or_xhr:
abort(403, f"You are blocking @{u.username}.")
return render_template("userpage/blocking.html", u=u, v=v), 403
@ -904,7 +902,6 @@ def u_username_wall_comment(v:User, username:str, cid):
@app.get("/@<username>/posts")
@app.get("/@<username>/posts.json")
@limiter.limit(DEFAULT_RATELIMIT)
@auth_desired_with_logingate
def u_username(v:Optional[User], username:str):
@ -913,14 +910,14 @@ def u_username(v:Optional[User], username:str):
return redirect(SITE_FULL + request.full_path.replace(username, u.username))
if v and hasattr(u, 'is_blocking') and u.is_blocking:
if g.is_api_or_xhr or request.path.endswith(".json"):
if g.is_api_or_xhr:
abort(403, f"You are blocking @{u.username}.")
return render_template("userpage/blocking.html", u=u, v=v), 403
is_following = v and u.has_follower(v)
if not u.is_visible_to(v):
if g.is_api_or_xhr or request.path.endswith(".json"):
if g.is_api_or_xhr:
abort(403, f"@{u.username}'s userpage is private")
return render_template("userpage/private.html", u=u, v=v, is_following=is_following), 403
@ -953,7 +950,7 @@ def u_username(v:Optional[User], username:str):
listing = get_posts(ids, v=v, eager=True)
if u.unban_utc:
if (v and v.client) or request.path.endswith(".json"):
if v and v.client:
return {"data": [x.json(g.db) for x in listing]}
return render_template("userpage/submissions.html",
@ -967,7 +964,7 @@ def u_username(v:Optional[User], username:str):
next_exists=next_exists,
is_following=is_following)
if (v and v.client) or request.path.endswith(".json"):
if v and v.client:
return {"data": [x.json(g.db) for x in listing]}
return render_template("userpage/submissions.html",
@ -982,7 +979,6 @@ def u_username(v:Optional[User], username:str):
@app.get("/@<username>/comments")
@app.get("/@<username>/comments.json")
@limiter.limit(DEFAULT_RATELIMIT)
@auth_desired_with_logingate
def u_username_comments(username, v=None):
@ -991,14 +987,14 @@ def u_username_comments(username, v=None):
return redirect(f"/@{u.username}/comments")
if v and hasattr(u, 'is_blocking') and u.is_blocking:
if g.is_api_or_xhr or request.path.endswith(".json"):
if g.is_api_or_xhr:
abort(403, f"You are blocking @{u.username}.")
return render_template("userpage/blocking.html", u=u, v=v), 403
is_following = v and u.has_follower(v)
if not u.is_visible_to(v):
if g.is_api_or_xhr or request.path.endswith(".json"):
if g.is_api_or_xhr:
abort(403, f"@{u.username}'s userpage is private")
return render_template("userpage/private.html", u=u, v=v, is_following=is_following), 403
@ -1044,7 +1040,7 @@ def u_username_comments(username, v=None):
listing = get_comments(ids, v=v)
if (v and v.client) or request.path.endswith(".json"):
if v and v.client:
return {"data": [c.json(g.db) for c in listing]}
return render_template("userpage/comments.html", u=u, v=v, listing=listing, page=page, sort=sort, t=t,next_exists=next_exists, is_following=is_following, standalone=True)