users and search: add status codes

master
justcool393 2022-10-30 02:33:42 -05:00
parent 5d2f4d203b
commit 7f716a6e72
2 changed files with 4 additions and 4 deletions

View File

@ -85,7 +85,7 @@ def searchposts(v):
domain=None,
domain_obj=None,
error=f"@{author.username}'s profile is private; You can't use the 'author' syntax on them."
)
), 403
else: posts = posts.filter(Submission.author_id == author.id)
if 'q' in criteria:
@ -199,7 +199,7 @@ def searchcomments(v):
if v.client:
abort(403, f"@{author.username}'s profile is private; You can't use the 'author' syntax on them")
return render_template("search_comments.html", v=v, query=query, total=0, page=page, comments=[], sort=sort, t=t, next_exists=False, error=f"@{author.username}'s profile is private; You can't use the 'author' syntax on them.")
return render_template("search_comments.html", v=v, query=query, total=0, page=page, comments=[], sort=sort, t=t, next_exists=False, error=f"@{author.username}'s profile is private; You can't use the 'author' syntax on them."), 403
else: comments = comments.filter(Comment.author_id == author.id)

View File

@ -742,12 +742,12 @@ def u_username_comments(username, v=None):
if not u.is_visible_to(v):
if g.is_api_or_xhr or request.path.endswith(".json"):
abort(403, "This userpage is private")
return render_template("userpage_private.html", u=u, v=v)
return render_template("userpage_private.html", u=u, v=v), 403
if v and hasattr(u, 'is_blocking') and u.is_blocking:
if g.is_api_or_xhr or request.path.endswith(".json"):
abort(403, f"You are blocking @{u.username}.")
return render_template("userpage_blocking.html", u=u, v=v)
return render_template("userpage_blocking.html", u=u, v=v), 403
try: page = max(int(request.values.get("page", "1")), 1)
except: page = 1