diff --git a/files/classes/comment.py b/files/classes/comment.py index 74833cb6c..9703926fe 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -326,6 +326,14 @@ class Comment(Base): url_noquery = url.split('?')[0] body = body.replace(url, f"{url_noquery}?{urlencode(p, True)}") + + if v and v.shadowbanned and self.author and self.author.shadowbanned and 86400 > time.time() - self.created_utc > 600: + rand = random.randint(5,20) + if self.upvotes < rand: + self.upvotes = rand + g.db.add(self) + g.db.commit() + return body def plainbody(self, v): diff --git a/files/classes/submission.py b/files/classes/submission.py index 75ac87791..d22e0e5f4 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -327,6 +327,14 @@ class Submission(Base): if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com") if v and v.nitter: body = body.replace("www.twitter.com", "nitter.net").replace("twitter.com", "nitter.net") + + if v and v.shadowbanned and self.author and self.author.shadowbanned and 86400 > time.time() - self.created_utc > 600: + rand = random.randint(5,20) + if self.upvotes < rand: + self.upvotes = rand + g.db.add(self) + g.db.commit() + return body def plainbody(self, v): diff --git a/files/routes/front.py b/files/routes/front.py index 86f4ed1ec..d805febbb 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -237,14 +237,6 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' posts = posts[:size] - if v and v.shadowbanned: - for post in posts: - if post.author and post.author.shadowbanned and 86400 > time.time() - post.created_utc > 600: - rand = random.randint(5,20) - if post.upvotes < rand: post.upvotes = rand - g.db.add(post) - g.db.commit() - pins = g.db.query(Submission).filter(Submission.stickied != None, Submission.is_banned == False) if v and v.admin_level == 0: blocking = [x[0] for x in g.db.query(UserBlock.target_id).filter_by(user_id=v.id).all()] diff --git a/files/routes/posts.py b/files/routes/posts.py index 42863ed18..b51f1b55a 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -175,12 +175,6 @@ def post_id(pid, anything=None, v=None): post.replies = [x for x in output if x.is_pinned] + [x for x in output if x.level == 1 and not x.is_pinned] - if v.shadowbanned: - for comment in post.replies: - if comment.author and comment.author.shadowbanned and 86400 > time.time() - comment.created_utc > 600: - rand = random.randint(5,20) - if comment.upvotes < rand: comment.upvotes = rand - g.db.add(comment) else: comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ACCOUNT) diff --git a/files/routes/users.py b/files/routes/users.py index 59160d48f..2f07adada 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -462,14 +462,6 @@ def u_username(username, v=None): listing = get_posts(ids, v=v) - if v and v.shadowbanned: - for post in listing: - if post.author and post.author.shadowbanned and 86400 > time.time() - post.created_utc > 600: - rand = random.randint(5,20) - if post.upvotes < rand: post.upvotes = rand - g.db.add(post) - g.db.commit() - if u.unban_utc: if request.headers.get("Authorization"): {"data": [x.json for x in listing]} else: return render_template("userpage.html",