From 2057c48ebdf7f3619e7ab782457b935c235cd14f Mon Sep 17 00:00:00 2001 From: Snakes Date: Sun, 4 Dec 2022 20:23:48 -0500 Subject: [PATCH] Fix userpage walls for logged-out viewers. --- files/routes/users.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/files/routes/users.py b/files/routes/users.py index 483b05cc5..df8542bd7 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -733,7 +733,10 @@ def u_username_wall(username, v=None): try: page = max(int(request.values.get("page", "1")), 1) except: page = 1 - comments, output = get_comments_v_properties(v, True, None, Comment.wall_user_id == u.id) + if v: + comments, output = get_comments_v_properties(v, True, None, Comment.wall_user_id == u.id) + else: + comments = g.db.query(Comment).filter(Comment.wall_user_id == u.id) comments = comments.filter(Comment.level == 1) if not v or (v.id != u.id and v.admin_level < PERMS['POST_COMMENT_MODERATION']): @@ -743,8 +746,10 @@ def u_username_wall(username, v=None): Comment.deleted_utc == 0 ) - comments = comments.order_by(Comment.created_utc.desc()).offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE+1) - comments = [c[0] for c in comments.all()] + comments = comments.order_by(Comment.created_utc.desc()) \ + .offset(PAGE_SIZE * (page - 1)).limit(PAGE_SIZE+1).all() + if v: + comments = [c[0] for c in comments] next_exists = (len(comments) > PAGE_SIZE) comments = comments[:PAGE_SIZE]