From de72ba49eb32f88f5deda010b95de9e6443ad851 Mon Sep 17 00:00:00 2001 From: Aevann Date: Fri, 6 Oct 2023 14:38:58 +0300 Subject: [PATCH] add /bm --- files/routes/allroutes.py | 4 ++-- files/routes/users.py | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/files/routes/allroutes.py b/files/routes/allroutes.py index e27e27925..28701ac4c 100644 --- a/files/routes/allroutes.py +++ b/files/routes/allroutes.py @@ -14,14 +14,14 @@ def before_request(): if request.host != SITE: abort(403, "Unauthorized host provided!") - if SITE == 'marsey.world' and request.path != '/kofi': + if SITE == 'marsey.world' and request.path not in {'/kofi','/bm'}: abort(404) if request.headers.get("CF-Worker"): abort(403, "Cloudflare workers are not allowed to access this website!") g.agent = request.headers.get("User-Agent", "") - if not g.agent and request.path not in {'/kofi', '/refresh_chat'}: + if not g.agent and request.path not in {'/kofi', '/bm', '/refresh_chat'}: abort(403, 'Please use a "User-Agent" header!') if not get_setting('bots') and request.headers.get("Authorization"): diff --git a/files/routes/users.py b/files/routes/users.py index 51af5d4d2..96748c40b 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1364,6 +1364,39 @@ if KOFI_TOKEN: return '' + +@app.post("/bm") +@limiter.exempt +def bm(): + print([x for x in request.form.items()], flush=True) + data = json.loads(request.values['data']) + print(data, flush=True) + + print(request.headers.get('CF-Connecting-IP'), flush=True) + # 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 + # ) + + # g.db.add(transaction) + + # claim_rewards_all_users() + + return '' + @app.post("/gumroad") @limiter.exempt def gumroad():