From afb9cad5e07a41b7e0643f530e86ddd9c7ae6a88 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 14 Sep 2021 20:18:28 +0200 Subject: [PATCH] hgh --- files/helpers/get.py | 8 +++++--- files/routes/front.py | 32 ++++++++++++++++---------------- files/routes/users.py | 2 +- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/files/helpers/get.py b/files/helpers/get.py index e143b96d9..864832ee7 100644 --- a/files/helpers/get.py +++ b/files/helpers/get.py @@ -192,7 +192,7 @@ def get_comment(i, v=None, graceful=False, **kwargs): return comment -def get_comments(cids, v=None, load_parent=False, shadowbanned=False): +def get_comments(cids, v=None, load_parent=False): if not cids: return [] @@ -212,6 +212,9 @@ def get_comments(cids, v=None, load_parent=False, shadowbanned=False): blocked.c.id, ).filter(Comment.id.in_(cids)) + if not (v and v.shadowbanned) and not (v and v.admin_level == 6): + comments = comments.join(Comment.author).filter(User.shadowbanned == False) + comments = comments.join( votes, votes.c.comment_id == Comment.id, @@ -229,14 +232,13 @@ def get_comments(cids, v=None, load_parent=False, shadowbanned=False): output = [] for c in comments: comment = c[0] - if comment.author and comment.author.shadowbanned and v.id != comment.author_id and not (shadowbanned and v.admin_level==6): continue comment.voted = c[1] or 0 comment._is_blocking = c[2] or 0 comment._is_blocked = c[3] or 0 output.append(comment) else: - output = g.db.query(Comment).filter(Comment.id.in_(cids)).all() + output = g.db.query(Comment).join(Comment.author).filter(Comment.id.in_(cids), User.shadowbanned == False).all() if load_parent: parents = [x.parent_comment_id for x in output if x.parent_comment_id] diff --git a/files/routes/front.py b/files/routes/front.py index e343f99a5..a2a7341c6 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -185,22 +185,22 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' secondrange = firstrange+100 posts = posts[firstrange:secondrange] - if random.random() < 0.004: - for post in posts: - if post.author and post.author.shadowbanned: - rand = random.randint(5,20) - if post.score > rand: continue - rand = random.randint(500,1400) - vote = Vote(user_id=rand, - vote_type=random.choice([-1, 1, 1, 1, 1]), - submission_id=post.id) - g.db.add(vote) - try: g.db.flush() - except: g.db.rollback() - post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count() - post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count() - post.views = post.views + random.randint(7,10) - g.db.add(post) + # if random.random() < 0.004: + # for post in posts: + # if post.author and post.author.shadowbanned: + # rand = random.randint(5,20) + # if post.score > rand: continue + # rand = random.randint(500,1400) + # vote = Vote(user_id=rand, + # vote_type=random.choice([-1, 1, 1, 1, 1]), + # submission_id=post.id) + # g.db.add(vote) + # try: g.db.flush() + # except: g.db.rollback() + # post.upvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=1).count() + # post.downvotes = g.db.query(Vote).filter_by(submission_id=post.id, vote_type=-1).count() + # post.views = post.views + random.randint(7,10) + # g.db.add(post) next_exists = (len(posts) > 25) diff --git a/files/routes/users.py b/files/routes/users.py index a1ee425c5..0067a7280 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -553,7 +553,7 @@ def u_username_comments(username, v=None): next_exists = (len(ids) > 25) ids = ids[:25] - listing = get_comments(ids, v=v, shadowbanned=True) + listing = get_comments(ids, v=v) is_following = (v and user.has_follower(v))