From 0b0ad438a8503e7b3ec875c67c3fdf821760fc05 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 17 Mar 2023 17:57:31 +0200 Subject: [PATCH] add SITE_FULL_IMAGES const --- files/helpers/actions.py | 4 ++-- files/helpers/config/const.py | 8 ++++++-- files/helpers/media.py | 6 ++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/files/helpers/actions.py b/files/helpers/actions.py index 006802e6d..ba5f4dabd 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -113,7 +113,7 @@ def execute_snappy(post:Submission, v:User): body += "\n\n" - if post.url and not post.url.startswith('/') and not post.url.startswith(SITE_FULL) and not post.url.startswith(BAN_EVASION_FULL): + if post.url and not post.url.startswith('/') and not post.url.startswith(SITE_FULL) and not post.url.startswith(SITE_FULL_IMAGES) and not post.url.startswith(BAN_EVASION_FULL): if post.url.startswith('https://old.reddit.com/r/'): rev = post.url.replace('https://old.reddit.com/', '') rev = f"* [unddit.com](https://unddit.com/{rev})\n\n" @@ -142,7 +142,7 @@ def execute_snappy(post:Submission, v:User): for href, title in captured: - if href.startswith(SITE_FULL) or href.startswith(BAN_EVASION_FULL): continue + if href.startswith(SITE_FULL) or href.startswith(SITE_FULL_IMAGES) or href.startswith(BAN_EVASION_FULL): continue if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n" if f'**[{title}]({href})**:\n\n' not in body: addition = f'**[{title}]({href})**:\n\n' diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 64c00142f..a0b49ea98 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -64,8 +64,12 @@ PUSH_NOTIF_LIMIT = 1000 IS_LOCALHOST = SITE == "localhost" or SITE == "127.0.0.1" or SITE.startswith("192.168.") or SITE.endswith(".local") -if IS_LOCALHOST: SITE_FULL = 'http://' + SITE -else: SITE_FULL = 'https://' + SITE +if IS_LOCALHOST: + SITE_FULL = 'http://' + SITE + SITE_FULL_IMAGES = SITE_FULL +else: + SITE_FULL = 'https://' + SITE + SITE_FULL_IMAGES = 'https://i.' + SITE LOGGED_IN_CACHE_KEY = f"{SITE}_loggedin" LOGGED_OUT_CACHE_KEY = f"{SITE}_loggedout" diff --git a/files/helpers/media.py b/files/helpers/media.py index bd4c4732f..a9528d978 100644 --- a/files/helpers/media.py +++ b/files/helpers/media.py @@ -21,8 +21,7 @@ from files.helpers.settings import get_setting from .config.const import * def remove_media_using_link(path): - img_prefix = f'https://i.{SITE}' - if path.startswith(img_prefix): + if path.startswith(SITE_FULL_IMAGES): path = path.split(img_prefix, 1)[1] video_prefix = f'https://videos.{SITE}' @@ -269,8 +268,7 @@ def process_image(filename:str, v, resize=0, trim=False, uploader_id:Optional[in ) db.add(media) - if IS_LOCALHOST: return f'{SITE_FULL}{filename}' - return f'https://i.{SITE}{filename}' + return f'{SITE_FULL_IMAGES}{filename}' def process_dm_images(v, user, body):