From 43b4162378833d3dbe1ebb983437e2c3c4fb3082 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sun, 8 Oct 2023 21:58:12 +0300 Subject: [PATCH] one less env var --- env_template.env | 3 +-- files/helpers/config/const.py | 9 +++++++-- files/templates/donate.html | 4 ++-- files/templates/settings/personal.html | 2 +- files/templates/settings/security.html | 2 +- 5 files changed, 12 insertions(+), 8 deletions(-) diff --git a/env_template.env b/env_template.env index ffdd80064..416984d4a 100644 --- a/env_template.env +++ b/env_template.env @@ -13,8 +13,7 @@ export TURNSTILE_SECRET='blahblahblah' export YOUTUBE_KEY='blahblahblah' export VAPID_PUBLIC_KEY='blahblahblah' export VAPID_PRIVATE_KEY='blahblahblah' -export DONATE_SERVICE='blahblahblah' -export DONATE_LINK='https://blahblahblah' +export DONATE_LINK='blahblahblah' export CF_KEY='blahblahblah' export CF_ZONE='blahblahblah' export DEBIAN_FRONTEND='noninteractive' diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index b1e36606f..6fde05c5c 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -34,8 +34,6 @@ TURNSTILE_SECRET = environ.get("TURNSTILE_SECRET").strip() YOUTUBE_KEY = environ.get("YOUTUBE_KEY").strip() VAPID_PUBLIC_KEY = environ.get("VAPID_PUBLIC_KEY").strip() VAPID_PRIVATE_KEY = environ.get("VAPID_PRIVATE_KEY").strip() -DONATE_SERVICE = environ.get("DONATE_SERVICE").strip() -DONATE_LINK = environ.get("DONATE_LINK").strip() CF_KEY = environ.get("CF_KEY").strip() CF_ZONE = environ.get("CF_ZONE").strip() blackjack = environ.get("BLACKJACK", "").strip() @@ -44,6 +42,13 @@ PROGSTACK_MUL = float(environ.get("PROGSTACK_MUL", 2.0)) ENCOURAGED = environ.get("ENCOURAGED", "").strip().split() ENCOURAGED2 = environ.get("ENCOURAGED2", "").strip().split() +DONATE_LINK = environ.get("DONATE_LINK").strip() + +if DONATE_LINK == DEFAULT_CONFIG_VALUE: + DONATE_SERVICE = DONATE_LINK +else: + DONATE_SERVICE = tldextract.extract(DONATE_LINK).domain.capitalize() + class Service(Enum): RDRAMA = auto() CHAT = auto() diff --git a/files/templates/donate.html b/files/templates/donate.html index 073c62ef1..644c0ff86 100644 --- a/files/templates/donate.html +++ b/files/templates/donate.html @@ -5,7 +5,7 @@
- {% if DONATE_SERVICE != DEFAULT_CONFIG_VALUE and v and v.can_see_countryclub and v.chud != 1 %} + {% if DONATE_LINK != DEFAULT_CONFIG_VALUE and v and v.can_see_countryclub and v.chud != 1 %} @@ -25,7 +25,7 @@
{{DONATE_SERVICE}} {{DONATE_LINK}}
- {% if v and v.truescore >= TRUESCORE_MINIMUM and DONATE_SERVICE != DEFAULT_CONFIG_VALUE %} + {% if v and v.truescore >= TRUESCORE_MINIMUM and DONATE_LINK != DEFAULT_CONFIG_VALUE %}
  • If you donate via {{DONATE_SERVICE}}, please first verify your email on the site, and then use that same email on {{DONATE_SERVICE}} to get your {{patron}} rewards automatically!
  • diff --git a/files/templates/settings/personal.html b/files/templates/settings/personal.html index c7b73f898..c4a49d091 100644 --- a/files/templates/settings/personal.html +++ b/files/templates/settings/personal.html @@ -16,7 +16,7 @@

    You're a {{TIER_TO_NAME[v.patron] if v.patron else "freeloader"}}!

    {% if v.patron %} Thanks ily! <3{% endif %} - {% if not v.patron and v.truescore >= TRUESCORE_MINIMUM and DONATE_SERVICE != DEFAULT_CONFIG_VALUE %} + {% if not v.patron and v.truescore >= TRUESCORE_MINIMUM and DONATE_LINK != DEFAULT_CONFIG_VALUE %}

    To stop freeloading, first verify your email, support us on {{DONATE_SERVICE}} with the same email, and click "Claim {{patron}} Rewards"

    {% elif not v.patron %}

    To stop freeloading, you can donate via crypto. Please let us know first beforehand by sending us a modmail. Thanks!

    diff --git a/files/templates/settings/security.html b/files/templates/settings/security.html index 4e0ae379b..fc18b1251 100644 --- a/files/templates/settings/security.html +++ b/files/templates/settings/security.html @@ -43,7 +43,7 @@ {% endif %}
    - {% if v.truescore >= TRUESCORE_MINIMUM and DONATE_SERVICE != DEFAULT_CONFIG_VALUE %} + {% if v.truescore >= TRUESCORE_MINIMUM and DONATE_LINK != DEFAULT_CONFIG_VALUE %}
    Must be same email as the one you used to donate on {{DONATE_SERVICE}}