From c94ffa3adf068ebedd7c7cf96c7e50891519397b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 3 Dec 2021 21:05:54 +0200 Subject: [PATCH 01/13] fdfd --- files/routes/votes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/routes/votes.py b/files/routes/votes.py index 3b3b574bd..a03e16ca0 100644 --- a/files/routes/votes.py +++ b/files/routes/votes.py @@ -101,7 +101,7 @@ def api_vote_post(post_id, new, v): post.author.coins += 1 post.author.truecoins += 1 g.db.add(post.author) - real = bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor + real = bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor and not v.agendaposter and not v.shadowbanned vote = Vote(user_id=v.id, vote_type=new, submission_id=post_id, @@ -169,7 +169,7 @@ def api_vote_comment(comment_id, new, v): comment.author.coins += 1 comment.author.truecoins += 1 g.db.add(comment.author) - real = bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor + real = (bool(v.profileurl) or bool(v.customtitle) or v.namecolor != defaultcolor) and not v.agendaposter and not v.shadowbanned vote = CommentVote(user_id=v.id, vote_type=new, comment_id=comment_id, From 6e54b9dccf643afffd4f384804cca862dbd98d4b Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 3 Dec 2021 21:20:52 +0200 Subject: [PATCH 02/13] sfddsf --- files/classes/user.py | 27 +++++++++++++++++++-------- files/routes/admin.py | 11 +++-------- files/routes/settings.py | 13 +++++-------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 79031f88a..67d3aa392 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -15,7 +15,7 @@ from .clients import * from files.__main__ import Base, cache from files.helpers.security import * import random -from os import environ, remove +from os import environ, remove, path site = environ.get("DOMAIN").strip() site_name = environ.get("SITE_NAME").strip() @@ -466,18 +466,29 @@ class User(Base): return data - def ban(self, admin=None, reason=None, days=0): + def deletepfp(self): + if self.highres and '/images/' in self.highres: + image = '/images/' + self.highres.split('/images/')[1] + if path.exists(image): remove(image) + if self.profileurl and '/images/' in self.profileurl: + image = '/images/' + self.profileurl.split('/images/')[1] + if path.exists(image): remove(image) + self.highres = None + self.profileurl = None + def deletebanner(self): + if self.bannerurl and '/images/' in self.bannerurl: + image = '/images/' + self.bannerurl.split('/images/')[1] + if path.exists(image): remove(image) + self.bannerurl = None + + def ban(self, admin=None, reason=None, days=0): if days > 0: ban_time = int(time.time()) + (days * 86400) self.unban_utc = ban_time else: - if self.highres and '/images/' in self.highres: remove('/images/' + self.highres.split('/images/')[1]) - if self.profileurl and '/images/' in self.profileurl: remove('/images/' + self.profileurl.split('/images/')[1]) - if self.bannerurl and '/images/' in self.bannerurl: remove('/images/' + self.bannerurl.split('/images/')[1]) - - self.bannerurl = None - self.profileurl = None + self.deletepfp() + self.deletebanner() if self.discord_id: remove_user(self) self.is_banned = admin.id if admin else AUTOJANNY_ID diff --git a/files/routes/admin.py b/files/routes/admin.py index 7bc45fead..09fb995d7 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -754,14 +754,9 @@ def ban_user(user_id, v): if user.admin_level >= v.admin_level: abort(403) - if 'form' in request.values: - days = float(request.values.get("days")) if request.values.get('days') else 0 - reason = sanitize(request.values.get("reason", ""))[:256] - message = request.values.get("reason", "").strip()[:256] - else: - days = float(request.values.get("days")) if request.values.get('days') else 0 - reason = sanitize(request.values.get("reason", ""))[:256] - message = request.values.get("reason", "").strip()[:256] + days = float(request.values.get("days")) if request.values.get('days') else 0 + reason = sanitize(request.values.get("reason", ""))[:256] + message = request.values.get("reason", "").strip()[:256] if not user: abort(400) diff --git a/files/routes/settings.py b/files/routes/settings.py index 0401c2108..e963c9cb0 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -762,13 +762,11 @@ def settings_images_banner(v): @validate_formkey def settings_delete_profile(v): - if v.highres and '/images/' in v.highres: os.remove('/images/' + v.highres.split('/images/')[1]) - if v.profileurl and '/images/' in v.profileurl: os.remove('/images/' + v.profileurl.split('/images/')[1]) + if v.profileurl or v.highres: + v.deletepfp() + g.db.add(v) + g.db.commit() - v.highres = None - v.profileurl = None - g.db.add(v) - g.db.commit() return render_template("settings_profile.html", v=v, msg="Profile picture successfully removed.") @@ -779,8 +777,7 @@ def settings_delete_profile(v): def settings_delete_banner(v): if v.bannerurl: - if '/images/' in v.bannerurl: os.remove('/images/' + v.bannerurl.split('/images/')[1]) - v.bannerurl = None + v.deletebanner() g.db.add(v) g.db.commit() From c000a05b48046bf5cc269677d5be47c092361745 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 3 Dec 2021 21:38:35 +0200 Subject: [PATCH 03/13] dsfsdf --- files/templates/comments.html | 110 +++++++++++++++++----------------- 1 file changed, 54 insertions(+), 56 deletions(-) diff --git a/files/templates/comments.html b/files/templates/comments.html index 4d16598d6..6e7c529d8 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -106,36 +106,6 @@ {% macro single_comment(c, level=1) %} -{% if p and not (v and v.id==c.author_id) and (not v or v.highlightcomments) %} - -{% endif %} - - - - +