remotes/1693045480750635534/spooky-22
Aevann1 2021-09-14 20:18:28 +02:00
parent 4bcd67a107
commit afb9cad5e0
3 changed files with 22 additions and 20 deletions

View File

@ -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]

View File

@ -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)

View File

@ -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))