diff --git a/files/routes/comments.py b/files/routes/comments.py index 55bdd6997..8e46fb476 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -474,7 +474,7 @@ def api_comment(v): 'notification': { 'title': f'New reply by @{c.author_name}', 'body': notifbody, - 'deep_link': f'https://{site}/comment/{c.id}?context=9&read=true#context', + 'deep_link': f'{request.host_url}comment/{c.id}?context=9&read=true#context', 'icon': f'{request.host_url}assets/images/{SITE_NAME}/icon.webp', } }, diff --git a/files/routes/discord.py b/files/routes/discord.py index 912735b6d..18b16ee93 100644 --- a/files/routes/discord.py +++ b/files/routes/discord.py @@ -58,7 +58,7 @@ def discord_redirect(v): 'client_secret': CLIENT_SECRET, 'grant_type': 'authorization_code', 'code': code, - 'redirect_uri': f"https://{app.config['SERVER_NAME']}/discord_redirect", + 'redirect_uri': f"{request.host_url}discord_redirect", 'scope': 'identify guilds.join' } headers={ diff --git a/files/routes/feeds.py b/files/routes/feeds.py index de35acd7f..06e7e2592 100644 --- a/files/routes/feeds.py +++ b/files/routes/feeds.py @@ -53,7 +53,7 @@ def feeds_user(v=None, sort='hot', t='all'): with tag("name"): text(post.author.username) with tag("uri"): - text(f'https://{site}/@{post.author.username}') + text(f'{request.host_url}@{post.author.username}') doc.stag("link", href=full_link(post.permalink)) diff --git a/files/routes/login.py b/files/routes/login.py index 352654661..c263cb600 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -366,7 +366,7 @@ def post_forgot(): if user: now = int(time.time()) token = generate_hash(f"{user.id}+{now}+forgot+{user.login_nonce}") - url = f"https://{app.config['SERVER_NAME']}/reset?id={user.id}&time={now}&token={token}" + url = f"{request.host_url}reset?id={user.id}&time={now}&token={token}" send_mail(to_address=user.email, subject="Password Reset Request", @@ -487,7 +487,7 @@ def request_2fa_disable(): valid=int(time.time()) token=generate_hash(f"{user.id}+{user.username}+disable2fa+{valid}+{user.mfa_secret}+{user.login_nonce}") - action_url=f"https://{app.config['SERVER_NAME']}/reset_2fa?id={user.id}&t={valid}&token={token}" + action_url=f"{request.host_url}reset_2fa?id={user.id}&t={valid}&token={token}" send_mail(to_address=user.email, subject="2FA Removal Request", diff --git a/files/routes/posts.py b/files/routes/posts.py index 4887c2e85..5a5b26221 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -77,7 +77,7 @@ def publish(pid, v): cache.delete_memoized(User.userpagelisting) if v.admin_level > 1 and ("[changelog]" in post.title or "(changelog)" in post.title): - send_discord_message(f"https://{site}{post.permalink}") + send_discord_message(f"{request.host_url}{post.permalink[1:]}") cache.delete_memoized(changeloglist) g.db.commit() @@ -579,7 +579,7 @@ def thumbnail_thread(pid): fetch_url = post.url - if fetch_url.startswith('/'): fetch_url = f"https://{site}{fetch_url}" + if fetch_url.startswith('/'): fetch_url = f"{request.host_url}{fetch_url[1:]}" 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"} @@ -1053,7 +1053,7 @@ def submit_post(v): rev = f"* [unddit.com](https://unddit.com/{rev})\n" else: rev = '' newposturl = new_post.url - if newposturl.startswith('/'): newposturl = f"https://{site}{newposturl}" + if newposturl.startswith('/'): newposturl = f"{request.host_url}{newposturl[1:]}" body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{newposturl})\n* [archive.ph](https://archive.ph/?url={quote(newposturl)}&run=1) (click to archive)\n\n" gevent.spawn(archiveorg, newposturl) @@ -1105,7 +1105,7 @@ def submit_post(v): cache.delete_memoized(frontlist) cache.delete_memoized(User.userpagelisting) if v.admin_level > 1 and ("[changelog]" in new_post.title or "(changelog)" in new_post.title) and not new_post.private: - send_discord_message(f"https://{site}{new_post.permalink}") + send_discord_message(f"{request.host_url}{new_post.permalink[1:]}") cache.delete_memoized(changeloglist) if v.id in (PIZZASHILL_ID, HIL_ID): diff --git a/files/routes/settings.py b/files/routes/settings.py index 1710510e7..dfa9c0e0c 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -543,7 +543,7 @@ def settings_security_post(v): if new_email == v.email: return render_template("settings_security.html", v=v, error="That email is already yours!") - url = f"https://{app.config['SERVER_NAME']}/activate" + url = f"{request.host_url}activate" now = int(time.time())