diff --git a/env_template b/env_template index 756e3fa6b..0c0241e6f 100644 --- a/env_template +++ b/env_template @@ -13,7 +13,8 @@ export TURNSTILE_SECRET="blahblahblah" export YOUTUBE_KEY="blahblahblah" export VAPID_PUBLIC_KEY="blahblahblah" export VAPID_PRIVATE_KEY="blahblahblah" -export GUMROAD_LINK="blahblahblah" +export DONATE_SERVICE="blahblahblah" +export DONATE_LINK="https://blahblahblah" export CF_KEY="blahblahblah" export CF_ZONE="blahblahblah" export DEBIAN_FRONTEND="noninteractive" diff --git a/files/classes/__init__.py b/files/classes/__init__.py index e528d90bb..d8a8ab6c4 100644 --- a/files/classes/__init__.py +++ b/files/classes/__init__.py @@ -2,9 +2,6 @@ from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() -# then load our required constants... -from files.helpers.config.const import FEATURES, KOFI_TOKEN - # then load all of our classes :) from .alts import * from .clients import * diff --git a/files/helpers/config/const.py b/files/helpers/config/const.py index 4f81b69ab..e48a69ce6 100644 --- a/files/helpers/config/const.py +++ b/files/helpers/config/const.py @@ -42,15 +42,14 @@ 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() -GUMROAD_LINK = environ.get("GUMROAD_LINK").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() GLOBAL = environ.get("GLOBAL", "").strip() blackjack = environ.get("BLACKJACK", "").strip() blackjack2 = environ.get("BLACKJACK2", "").strip() FP = environ.get("FP", "").strip() -KOFI_TOKEN = environ.get("KOFI_TOKEN", "").strip() -KOFI_LINK = environ.get("KOFI_LINK", "").strip() PROGSTACK_MUL = float(environ.get("PROGSTACK_MUL", 2.0)) ENCOURAGED = environ.get("ENCOURAGED", "").strip().split() ENCOURAGED2 = environ.get("ENCOURAGED2", "").strip().split() @@ -665,8 +664,6 @@ LEADERBOARD_LIMIT = PAGE_SIZE HOUSE_JOIN_COST = 500 HOUSE_SWITCH_COST = 2000 -DONATE_SERVICE = "KoFi" if KOFI_TOKEN else "Gumroad" -DONATE_LINK = KOFI_LINK if KOFI_TOKEN else GUMROAD_LINK TIERS_ID_TO_NAME = { 1: "Paypig", 2: "Renthog", diff --git a/files/routes/jinja2.py b/files/routes/jinja2.py index e25902df6..1bd1f8c59 100644 --- a/files/routes/jinja2.py +++ b/files/routes/jinja2.py @@ -105,12 +105,11 @@ def inject_constants(): "PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "time":time, "PERMS":PERMS, "FEATURES":FEATURES, "HOLE_NAME":HOLE_NAME, "HOLE_STYLE_FLAIR":HOLE_STYLE_FLAIR, "HOLE_REQUIRED":HOLE_REQUIRED, - "GUMROAD_LINK":GUMROAD_LINK, "DEFAULT_THEME":DEFAULT_THEME, "DESCRIPTION":DESCRIPTION, + "DEFAULT_THEME":DEFAULT_THEME, "DESCRIPTION":DESCRIPTION, "has_sidebar":has_sidebar, "has_logo":has_logo, "FP":FP, "patron":patron, "get_setting": get_setting, "SIDEBAR_THREAD":SIDEBAR_THREAD, "BANNER_THREAD":BANNER_THREAD, "BADGE_THREAD":BADGE_THREAD, "SNAPPY_THREAD":SNAPPY_THREAD, - "KOFI_TOKEN":KOFI_TOKEN, "KOFI_LINK":KOFI_LINK, "approved_embed_hosts":approved_embed_hosts, "site_settings":get_settings(), "EMAIL":EMAIL, "max": max, "min": min, "user_can_see":User.can_see, "TELEGRAM_ID":TELEGRAM_ID, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN, diff --git a/files/routes/users.py b/files/routes/users.py index f08e1b6ad..d3858106d 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1302,39 +1302,39 @@ def claim_rewards(v): g.db.delete(badge) badge_grant(badge_id=20+highest_tier, user=v) +KOFI_TOKEN = environ.get("KOFI_TOKEN", "").strip() +if KOFI_TOKEN: + @app.post("/kofi") + def kofi(): + data = json.loads(request.values['data']) + verification_token = data['verification_token'] + if verification_token != KOFI_TOKEN: abort(400) -@app.post("/kofi") -def kofi(): - if not KOFI_TOKEN: abort(404) - data = json.loads(request.values['data']) - verification_token = data['verification_token'] - if verification_token != KOFI_TOKEN: abort(400) + id = data['kofi_transaction_id'] + created_utc = int(time.mktime(time.strptime(data['timestamp'].split('.')[0], "%Y-%m-%dT%H:%M:%SZ"))) + type = data['type'] + amount = 0 + try: + amount = int(float(data['amount'])) + except: + abort(400, 'invalid amount') + email = data['email'] - id = data['kofi_transaction_id'] - created_utc = int(time.mktime(time.strptime(data['timestamp'].split('.')[0], "%Y-%m-%dT%H:%M:%SZ"))) - type = data['type'] - amount = 0 - try: - amount = int(float(data['amount'])) - except: - abort(400, 'invalid amount') - email = data['email'] + transaction = Transaction( + id=id, + created_utc=created_utc, + type=type, + amount=amount, + email=email + ) - transaction = Transaction( - id=id, - created_utc=created_utc, - type=type, - amount=amount, - email=email - ) + g.db.add(transaction) - g.db.add(transaction) + user = g.db.query(User).filter_by(email=email, is_activated=True).order_by(User.truescore.desc()).first() + if user: + claim_rewards(user) - user = g.db.query(User).filter_by(email=email, is_activated=True).order_by(User.truescore.desc()).first() - if user: - claim_rewards(user) - - return '' + return '' @app.post("/gumroad") def gumroad(): diff --git a/files/templates/donate_WPD.html b/files/templates/donate_WPD.html index 09a9e04e9..68274ffba 100644 --- a/files/templates/donate_WPD.html +++ b/files/templates/donate_WPD.html @@ -7,8 +7,8 @@ {% if v and v.truescore >= TRUESCORE_DONATE_MINIMUM %} - Kofi - {{KOFI_LINK}} + {{DONATE_SERVICE}} + {{DONATE_LINK}} {% endif %} diff --git a/files/templates/donate_rDrama.html b/files/templates/donate_rDrama.html index 37e9c7e95..befe3a553 100644 --- a/files/templates/donate_rDrama.html +++ b/files/templates/donate_rDrama.html @@ -7,8 +7,8 @@ {% if v and v.truescore >= TRUESCORE_DONATE_MINIMUM %} - Gumroad - {{GUMROAD_LINK}} + {{DONATE_SERVICE}} + {{DONATE_LINK}} {% endif %} diff --git a/files/templates/settings/security.html b/files/templates/settings/security.html index 2feddf50b..017a95ec7 100644 --- a/files/templates/settings/security.html +++ b/files/templates/settings/security.html @@ -47,11 +47,7 @@ Must be same email as the one you used to donate {% if v.truescore >= TRUESCORE_DONATE_MINIMUM %} on - {% if KOFI_TOKEN %} - Kofi - {% else %} - Gumroad - {% endif %} + {{DONATE_SERVICE}} {% endif %} {% endif %}