From 951ba751c0b219875687319d595e0631be9d61bb Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 12 Nov 2021 16:06:22 +0200 Subject: [PATCH] gfgfgf --- files/classes/comment.py | 2 +- files/routes/front.py | 6 +++--- files/routes/posts.py | 18 +++++++++--------- files/routes/users.py | 9 ++++++++- files/templates/award_modal.html | 4 ++++ files/templates/notifications.html | 2 +- 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 7f900cccf..74833cb6c 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -363,7 +363,7 @@ class Comment(Base): if v.filter_words and self.body and any([x in self.body for x in v.filter_words]): return True - if self.is_banned or (self.author and self.author.shadowbanned and not v.shadowbanned): return True + if self.is_banned: return True return False diff --git a/files/routes/front.py b/files/routes/front.py index ba3788341..86f4ed1ec 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -237,11 +237,11 @@ def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, filter_words=' posts = posts[:size] - if random.random() < 0.02: + if v and v.shadowbanned: for post in posts: - if post.author and post.author.shadowbanned: + if post.author and post.author.shadowbanned and 86400 > time.time() - post.created_utc > 600: rand = random.randint(5,20) - if post.score < rand: post.upvotes += 1 + if post.upvotes < rand: post.upvotes = rand g.db.add(post) g.db.commit() diff --git a/files/routes/posts.py b/files/routes/posts.py index 5e2048c20..478dd576d 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -173,6 +173,13 @@ def post_id(pid, anything=None, v=None): output.append(comment) 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) @@ -189,13 +196,6 @@ def post_id(pid, anything=None, v=None): post.replies = comments.filter(Comment.is_pinned != None).all() + comments.filter(Comment.level == 1, Comment.is_pinned == None).all() - if random.random() < 0.02: - for comment in post.replies: - if comment.author and comment.author.shadowbanned: - rand = random.randint(5,20) - if comment.score < rand: comment.upvotes += 1 - g.db.add(comment) - post.views += 1 g.db.add(post) if isinstance(session.get('over_18', 0), dict): session["over_18"] = 0 @@ -685,9 +685,9 @@ def submit_post(v): body_md = CustomRenderer().render(mistletoe.Document(body)) body_html = sanitize(body_md) - if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 40 + if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', body_html))) > 0: return {"error":"You can only type marseys!"}, 400 - if len(body_html) > 20000: abort(400) + if len(body_html) > 20000: return {"error":"Submission body too long!"}, 400 bans = filter_comment_html(body_html) if bans: diff --git a/files/routes/users.py b/files/routes/users.py index f1affc23c..59160d48f 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -453,7 +453,6 @@ def u_username(username, v=None): next_exists = (len(ids) > 25) ids = ids[:25] - # If page 1, check for sticky if page == 1: sticky = [] sticky = g.db.query(Submission).filter_by(is_pinned=True, author_id=u.id).all() @@ -463,6 +462,14 @@ 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", diff --git a/files/templates/award_modal.html b/files/templates/award_modal.html index c38120a5c..b90ef5a02 100644 --- a/files/templates/award_modal.html +++ b/files/templates/award_modal.html @@ -33,6 +33,10 @@ +
+
+
+					
diff --git a/files/templates/notifications.html b/files/templates/notifications.html index 4f4a635d3..1999f56f6 100644 --- a/files/templates/notifications.html +++ b/files/templates/notifications.html @@ -42,7 +42,7 @@ -Clear all notifications +Clear all notifications