generated from nathanwoodburn/python-webserver-template
fix: Temp remove owner check since it doesn't work
All checks were successful
Build Docker / BuildImage (push) Successful in 45s
All checks were successful
Build Docker / BuildImage (push) Successful in 45s
This commit is contained in:
32
server.py
32
server.py
@@ -107,18 +107,24 @@ def renew():
|
||||
if not re.match(r"^[a-zA-Z0-9-]+$", domain):
|
||||
return redirect("/?error=invalid_domain")
|
||||
|
||||
# Check the owner is correct
|
||||
req = requests.get(f"https://api.niami.io/hsd/{domain}")
|
||||
if req.status_code != 200:
|
||||
return redirect("/?error=api_error")
|
||||
req = req.json()
|
||||
if req["success"] != True:
|
||||
return redirect("/?error=api_error")
|
||||
|
||||
if req["data"]["owner_tx_data"]["address"] not in allowed_owners:
|
||||
return redirect("/?error=not_anyone")
|
||||
try:
|
||||
# Check the owner is correct
|
||||
api = os.getenv("API")
|
||||
req = requests.get(f"{api}/verify?domain={domain}")
|
||||
print(json.dumps(req.json(), indent=4))
|
||||
if req.status_code != 200:
|
||||
return redirect("/?error=api_error")
|
||||
req = req.json()
|
||||
if req["error"] != None:
|
||||
return redirect("/?error=api_error")
|
||||
|
||||
# if req["result"]["owner_tx_data"]["address"] not in allowed_owners:
|
||||
# return redirect("/?error=not_anyone")
|
||||
|
||||
return redirect(f"https://pay.hns.au/p/renew?amount=10&data={domain}&redirect=https://renew.hns.au/?message=Pending:%20The%20domain%20will%20renew%20when%20the%20payment%20has%20arrived")
|
||||
return redirect(f"https://pay.hns.au/p/renew?amount=10&data={domain}&redirect=https://renew.hns.au/?message=Pending:%20The%20domain%20will%20renew%20when%20the%20payment%20has%20arrived")
|
||||
except requests.RequestException as e:
|
||||
print(f"Error fetching data for {domain}: {e}")
|
||||
return redirect("/?error=api_error")
|
||||
|
||||
@app.route("/renew/<path:path>", methods=["POST"])
|
||||
def renew_path(path: str):
|
||||
@@ -142,7 +148,7 @@ def renew_path(path: str):
|
||||
|
||||
# GET HS-anyone api route
|
||||
api = os.getenv("API")
|
||||
req = requests.post(api, json={"domain": data["data"]})
|
||||
req = requests.post(f"{api}/renew", json={"domain": data["data"]})
|
||||
if req.status_code != 200:
|
||||
return jsonify({"error": "API error"}), 400
|
||||
req = req.json()
|
||||
@@ -156,7 +162,7 @@ def renew_path(path: str):
|
||||
if req["error"] != "":
|
||||
message += "\n\nError: " + req["error"]
|
||||
else:
|
||||
message += "\n\nTX: https://hns.cymon.de/tx/" + req["output"].split("'")[1]
|
||||
message += "\n\nTX: https://shakeshift.com/transaction/" + req["output"].split("'")[1]
|
||||
|
||||
requests.post(webhook, json={"content": message})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user