From 28babbee6b710e184d3c9e10ac8102c88afe1f1d Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 16 Dec 2021 19:59:30 +0200 Subject: [PATCH] sdf --- files/classes/submission.py | 1 - files/routes/comments.py | 2 +- files/routes/posts.py | 4 +++- files/templates/CHRISTMAS/submission.html | 6 ++++-- files/templates/submission.html | 2 +- files/templates/submission_listing.html | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index db83abb06..897f5985a 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -207,7 +207,6 @@ class Submission(Base): @property @lazy def domain(self): - if self.is_image: return "image" domain = urlparse(self.url).netloc if domain.startswith("www."): domain = domain.split("www.")[1] return domain.replace("old.reddit.com", "reddit.com") diff --git a/files/routes/comments.py b/files/routes/comments.py index b4ad8e3d1..fd17f1934 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -230,7 +230,7 @@ def api_comment(v): if parent.author.any_block_exists(v) and v.admin_level < 2: return {"error": "You can't reply to users who have blocked you, or users you have blocked."}, 403 - is_bot = request.headers.get("Authorization") + is_bot = bool(request.headers.get("Authorization")) if not is_bot and not v.marseyawarded and 'trans lives matters' not in body.lower(): now = int(time.time()) diff --git a/files/routes/posts.py b/files/routes/posts.py index ae9f30ce2..c9efe9a9f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -603,7 +603,9 @@ def thumbnail_thread(pid): time.sleep(5) post = db.query(Submission).filter_by(id=pid).first() - fetch_url=post.url + fetch_url = post.url + + if fetch_url.startswith('/'): fetch_url = request.host_url[:-1] + fetch_url headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.72 Safari/537.36"} diff --git a/files/templates/CHRISTMAS/submission.html b/files/templates/CHRISTMAS/submission.html index 6c2c3a2b5..03d120743 100644 --- a/files/templates/CHRISTMAS/submission.html +++ b/files/templates/CHRISTMAS/submission.html @@ -302,8 +302,10 @@ {{p.edited_string}} {% endif %} - {% if p.realurl(v) %} - ({{p.domain}}) + {% if p.is_image %} + (image post) + {% elif p.realurl(v) %} + ({{p.domain}}) {% else %} (text post) diff --git a/files/templates/submission.html b/files/templates/submission.html index 4c160a478..bb9d3a9f1 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -322,7 +322,7 @@ {% endif %} {{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}  {{p.age_string}} - ({% if p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) + ({% if p.is_image %}image post{% elif p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) {% if p.edited_utc %}   Edited {{p.edited_string}} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index 25fac2ee1..89dd3884f 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -185,7 +185,7 @@ {{p.author.username}}{% if p.author.customtitle %}  {% if p.author.quadrant %}{% endif %}{{p.author.customtitle | safe}}{% endif %}  {{p.age_string}}   - ({% if p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) + ({% if p.is_image %}image post{% elif p.realurl(v) %}{{p.domain}}{% else %}text post{% endif %}) {% if p.edited_utc %}   Edited {{p.edited_string}} {% endif %}