From 6e1216d7b34bddd0a0616ffcb1a6fdcecd05cb40 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 23 Oct 2021 16:35:35 +0200 Subject: [PATCH] misc --- files/classes/comment.py | 8 ++------ files/classes/submission.py | 16 ++++++++-------- files/routes/comments.py | 4 ++-- files/routes/settings.py | 7 +++---- files/templates/comments.html | 2 +- files/templates/expanded_image_modal.html | 9 ++++++++- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 2 +- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/files/classes/comment.py b/files/classes/comment.py index 856bdd99f..1a595bfbf 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -293,9 +293,7 @@ class Comment(Base): return data def realbody(self, v): - if self.post and self.post.club and not (v and v.paid_dues): - if v: return f"

{v.username} dox/p>" - return "

COUNTRY CLUB ONLY

" + if self.post and self.post.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" body = self.body_html @@ -321,9 +319,7 @@ class Comment(Base): return body def plainbody(self, v): - if self.post and self.post.club and not (v and v.paid_dues): - if v: return f"

{v.username} dox/p>" - return "

COUNTRY CLUB ONLY

" + if self.post and self.post.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" body = self.body diff --git a/files/classes/submission.py b/files/classes/submission.py index d7fb9cd7c..24799816d 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -309,9 +309,7 @@ class Submission(Base): else: return "" def realbody(self, v): - if self.club and not (v and v.paid_dues): - if v: return f"

{v.username} dox/p>" - return "

COUNTRY CLUB ONLY

" + if self.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" body = self.body_html body = censor_slurs(body, v) @@ -321,9 +319,7 @@ class Submission(Base): return body def plainbody(self, v): - if self.club and not (v and v.paid_dues): - if v: return f"

{v.username} dox/p>" - return "

COUNTRY CLUB ONLY

" + if self.club and not (v and v.paid_dues): return "

COUNTRY CLUB ONLY

" body = self.body body = censor_slurs(body, v) @@ -334,7 +330,9 @@ class Submission(Base): @lazy def realtitle(self, v): - if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): return 'COUNTRY CLUB MEMBERS ONLY' + if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): + if v: return f'{v.username} dox' + else: return 'COUNTRY CLUB MEMBERS ONLY' elif self.title_html: title = self.title_html else: title = self.title @@ -344,7 +342,9 @@ class Submission(Base): @lazy def plaintitle(self, v): - if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): return 'COUNTRY CLUB MEMBERS ONLY' + if self.club and not (v and v.paid_dues) and not (v and v.admin_level == 6): + if v: return f'{v.username} dox' + else: return 'COUNTRY CLUB MEMBERS ONLY' else: title = self.title title = censor_slurs(title, v) diff --git a/files/routes/comments.py b/files/routes/comments.py index a382bbe75..13088db6b 100755 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -385,7 +385,7 @@ def api_comment(v): c.upvotes += 1 g.db.add(c) - if "rama" in request.host and len(c.body) >= 1000 and v.username != "Snappy" and "" not in body_html: + if "rama" in request.host and len(c.body) >= 1000 and "<" not in body and "" not in body_html: body = random.choice(LONGPOST_REPLIES) body = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', body) @@ -417,7 +417,7 @@ def api_comment(v): - if "rama" in request.host and random.random() < 0.001 and v.username != "Snappy" and v.username != "zozbot": + if "rama" in request.host and random.random() < 0.001: body = "zoz" body_md = CustomRenderer().render(mistletoe.Document(body)) diff --git a/files/routes/settings.py b/files/routes/settings.py index 133beb77d..9e0de5720 100755 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -101,15 +101,14 @@ def settings_profile_post(v): updated = True v.is_nofollow = request.values.get("nofollow", None) == 'true' - if request.values.get("bio") or request.files.get('file'): + if request.values.get("bio") or request.files.get('file') and request.headers.get("cf-ipcountry") != "T1": bio = request.values.get("bio")[:1500] for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', bio, re.MULTILINE): if "wikipedia" not in i.group(1): bio = bio.replace(i.group(1), f'![]({i.group(1)})') bio = re.sub('([^\n])\n([^\n])', r'\1\n\n\2', bio) - if request.files.get('file') and request.headers.get("cf-ipcountry") != "T1": - + if request.files.get('file'): file = request.files['file'] if not file.content_type.startswith('image/'): if request.headers.get("Authorization"): return {"error": f"Image files only"}, 400 @@ -120,7 +119,7 @@ def settings_profile_post(v): url = request.host_url[:-1] + process_image(name) bio += f"\n\n![]({url})" - + bio_html = CustomRenderer().render(mistletoe.Document(bio)) bio_html = sanitize(bio_html) bans = filter_comment_html(bio_html) diff --git a/files/templates/comments.html b/files/templates/comments.html index fc413e32c..1a6777d93 100755 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -281,7 +281,7 @@ {% if c.author.verified %} {% endif %} - {{c.author.username}} + {{c.author.username}} {% if c.author.customtitle %}  {% if c.author.quadrant %}{% endif %}{{c.author.customtitle | safe}}{% endif %} {% if c.parent_comment_id and not standalone and level<=7 %}{{ c.parent_comment.author.username }}{% endif %} diff --git a/files/templates/expanded_image_modal.html b/files/templates/expanded_image_modal.html index af9d21036..c1e452264 100755 --- a/files/templates/expanded_image_modal.html +++ b/files/templates/expanded_image_modal.html @@ -9,7 +9,7 @@