Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,7 +9,6 @@ import threading
|
|
| 9 |
from cryptography.fernet import Fernet
|
| 10 |
import os
|
| 11 |
import random
|
| 12 |
-
import string
|
| 13 |
|
| 14 |
STOCK_START_TIME = None
|
| 15 |
STOCK_START_PRICE_AN = 1.27
|
|
@@ -129,8 +128,21 @@ def encrypt_value(value):
|
|
| 129 |
def decrypt_value(encrypted_value):
|
| 130 |
return cipher_suite.decrypt(encrypted_value.encode()).decode()
|
| 131 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
def calculate_fee(amount):
|
| 133 |
-
"""Calculate astratrader fee based on tiered structure"""
|
| 134 |
if amount < 10:
|
| 135 |
return 0
|
| 136 |
elif amount < 25:
|
|
@@ -155,33 +167,34 @@ def calculate_fee(amount):
|
|
| 155 |
return 50
|
| 156 |
|
| 157 |
def calculate_claim_amounts(amount):
|
| 158 |
-
|
| 159 |
-
|
|
|
|
|
|
|
| 160 |
|
| 161 |
-
|
|
|
|
| 162 |
|
| 163 |
-
return send_amount, claim_amount
|
| 164 |
|
| 165 |
-
def generate_unique_code(
|
| 166 |
-
"""Generate a unique alphanumeric code (must be called within app context)"""
|
| 167 |
-
chars = string.ascii_uppercase + string.digits
|
| 168 |
max_attempts = 100
|
| 169 |
|
| 170 |
for _ in range(max_attempts):
|
| 171 |
-
code =
|
| 172 |
if not PaymentLink.query.filter_by(id=code).first() and not ClaimLink.query.filter_by(id=code).first():
|
| 173 |
return code
|
| 174 |
|
| 175 |
-
return
|
| 176 |
|
| 177 |
-
ENCRYPTED_CONNECT_SID = encrypt_value('s%3AchprkBWT1gzUWdCkJcWneCauTP73rb1-.
|
| 178 |
ENCRYPTED_API_URL = encrypt_value('https://astra-bank-moh1812.replit.app/api/transactions')
|
| 179 |
ENCRYPTED_REFERER = encrypt_value('https://astra-bank-moh1812.replit.app/')
|
| 180 |
ENCRYPTED_ETAG = encrypt_value('W/"6e3-L0zHI4rHMa4nHmyewyA/4y+lL6c"')
|
| 181 |
ENCRYPTED_BANK_BASE_URL = encrypt_value('https://astra-bank-moh1812.replit.app')
|
| 182 |
|
| 183 |
class PaymentLink(db.Model):
|
| 184 |
-
id = db.Column(db.String(
|
| 185 |
amount = db.Column(db.Integer, nullable=False)
|
| 186 |
description = db.Column(db.String(500), nullable=False)
|
| 187 |
recipient_email = db.Column(db.String(255), nullable=True)
|
|
@@ -192,7 +205,7 @@ class PaymentLink(db.Model):
|
|
| 192 |
return f'<PaymentLink {self.id}: {self.amount} Astras>'
|
| 193 |
|
| 194 |
class ClaimLink(db.Model):
|
| 195 |
-
id = db.Column(db.String(
|
| 196 |
amount = db.Column(db.Integer, nullable=False)
|
| 197 |
send_amount = db.Column(db.Integer, nullable=False)
|
| 198 |
claim_amount = db.Column(db.Integer, nullable=False)
|
|
@@ -375,6 +388,137 @@ def send_money(to_user_id, amount, description):
|
|
| 375 |
print(f"Error sending money: {e}")
|
| 376 |
return False, str(e)
|
| 377 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 378 |
with app.app_context():
|
| 379 |
db.create_all()
|
| 380 |
|
|
@@ -431,7 +575,7 @@ def create_payment_link():
|
|
| 431 |
@app.route('/init-payment-check/<payment_id>')
|
| 432 |
def init_payment_check(payment_id):
|
| 433 |
try:
|
| 434 |
-
payment_link = PaymentLink.query.get_or_404(payment_id
|
| 435 |
fee = calculate_fee(payment_link.amount)
|
| 436 |
total_amount = payment_link.amount + fee
|
| 437 |
|
|
@@ -447,7 +591,7 @@ def init_payment_check(payment_id):
|
|
| 447 |
@app.route('/check-payment/<payment_id>')
|
| 448 |
def check_payment_status(payment_id):
|
| 449 |
try:
|
| 450 |
-
payment_link = PaymentLink.query.get_or_404(payment_id
|
| 451 |
fee = calculate_fee(payment_link.amount)
|
| 452 |
total_amount = payment_link.amount + fee
|
| 453 |
|
|
@@ -472,7 +616,7 @@ def check_payment_status(payment_id):
|
|
| 472 |
@app.route('/pay/<payment_id>', methods=['POST'])
|
| 473 |
def process_payment(payment_id):
|
| 474 |
try:
|
| 475 |
-
payment_link = PaymentLink.query.get_or_404(payment_id
|
| 476 |
|
| 477 |
if payment_link.paid:
|
| 478 |
return jsonify({'error': 'Payment already completed'}), 400
|
|
@@ -508,23 +652,21 @@ def process_payment(payment_id):
|
|
| 508 |
|
| 509 |
@app.route('/check-link/<link_id>')
|
| 510 |
def check_link(link_id):
|
| 511 |
-
"""Check if a link ID exists and return its type"""
|
| 512 |
try:
|
| 513 |
-
payment_link = PaymentLink.query.filter_by(id=link_id
|
| 514 |
if payment_link:
|
| 515 |
return jsonify({
|
| 516 |
'exists': True,
|
| 517 |
'type': 'payment'
|
| 518 |
})
|
| 519 |
|
| 520 |
-
claim_link = ClaimLink.query.filter_by(id=link_id
|
| 521 |
if claim_link:
|
| 522 |
return jsonify({
|
| 523 |
'exists': True,
|
| 524 |
'type': 'claim'
|
| 525 |
})
|
| 526 |
|
| 527 |
-
# Not found
|
| 528 |
return jsonify({
|
| 529 |
'exists': False
|
| 530 |
}), 404
|
|
@@ -534,7 +676,7 @@ def check_link(link_id):
|
|
| 534 |
|
| 535 |
@app.route('/pay/<payment_id>')
|
| 536 |
def view_payment(payment_id):
|
| 537 |
-
payment_link = PaymentLink.query.get_or_404(payment_id
|
| 538 |
fee = calculate_fee(payment_link.amount)
|
| 539 |
total_amount = payment_link.amount + fee
|
| 540 |
return render_template('payment.html',
|
|
@@ -566,7 +708,7 @@ def create_claim_link():
|
|
| 566 |
if amount > 10000:
|
| 567 |
return jsonify({'error': 'Maximum 10,000 Astras per claim link'}), 400
|
| 568 |
|
| 569 |
-
send_amount, claim_amount = calculate_claim_amounts(amount)
|
| 570 |
|
| 571 |
claim_link = ClaimLink(
|
| 572 |
id=generate_unique_code(),
|
|
@@ -594,11 +736,15 @@ def create_claim_link():
|
|
| 594 |
|
| 595 |
@app.route('/claim/<claim_id>')
|
| 596 |
def view_claim(claim_id):
|
| 597 |
-
claim_link = ClaimLink.query.get_or_404(claim_id
|
|
|
|
|
|
|
| 598 |
return render_template('claim.html',
|
| 599 |
amount=claim_link.amount,
|
| 600 |
send_amount=claim_link.send_amount,
|
| 601 |
claim_amount=claim_link.claim_amount,
|
|
|
|
|
|
|
| 602 |
verified=claim_link.verified,
|
| 603 |
claimed=claim_link.claimed,
|
| 604 |
claimer_email=claim_link.claimer_email,
|
|
@@ -607,7 +753,7 @@ def view_claim(claim_id):
|
|
| 607 |
@app.route('/check-claim-verification/<claim_id>')
|
| 608 |
def check_claim_verification(claim_id):
|
| 609 |
try:
|
| 610 |
-
claim_link = ClaimLink.query.get_or_404(claim_id
|
| 611 |
|
| 612 |
if claim_link.verified:
|
| 613 |
return jsonify({'verified': True})
|
|
@@ -630,7 +776,7 @@ def check_claim_verification(claim_id):
|
|
| 630 |
def process_claim(claim_id):
|
| 631 |
try:
|
| 632 |
data = request.get_json()
|
| 633 |
-
claim_link = ClaimLink.query.get_or_404(claim_id
|
| 634 |
|
| 635 |
if claim_link.claimed:
|
| 636 |
return jsonify({'error': 'Claim link already used'}), 400
|
|
@@ -673,6 +819,10 @@ def handle_connect():
|
|
| 673 |
pass
|
| 674 |
|
| 675 |
if __name__ == '__main__':
|
| 676 |
-
|
| 677 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 678 |
socketio.run(app, debug=True, host='0.0.0.0', port=7860, allow_unsafe_werkzeug=True)
|
|
|
|
| 9 |
from cryptography.fernet import Fernet
|
| 10 |
import os
|
| 11 |
import random
|
|
|
|
| 12 |
|
| 13 |
STOCK_START_TIME = None
|
| 14 |
STOCK_START_PRICE_AN = 1.27
|
|
|
|
| 128 |
def decrypt_value(encrypted_value):
|
| 129 |
return cipher_suite.decrypt(encrypted_value.encode()).decode()
|
| 130 |
|
| 131 |
+
_CACHED_CONNECT_SID = None
|
| 132 |
+
_CACHED_BANK_BASE_URL = None
|
| 133 |
+
_CACHED_REFERER = None
|
| 134 |
+
|
| 135 |
+
def get_cached_credentials():
|
| 136 |
+
global _CACHED_CONNECT_SID, _CACHED_BANK_BASE_URL, _CACHED_REFERER
|
| 137 |
+
if _CACHED_CONNECT_SID is None:
|
| 138 |
+
_CACHED_CONNECT_SID = decrypt_value(ENCRYPTED_CONNECT_SID)
|
| 139 |
+
_CACHED_BANK_BASE_URL = decrypt_value(ENCRYPTED_BANK_BASE_URL)
|
| 140 |
+
_CACHED_REFERER = decrypt_value(ENCRYPTED_REFERER)
|
| 141 |
+
if not _CACHED_CONNECT_SID:
|
| 142 |
+
raise ValueError("connect.sid cookie is empty or invalid")
|
| 143 |
+
return _CACHED_CONNECT_SID, _CACHED_BANK_BASE_URL, _CACHED_REFERER
|
| 144 |
+
|
| 145 |
def calculate_fee(amount):
|
|
|
|
| 146 |
if amount < 10:
|
| 147 |
return 0
|
| 148 |
elif amount < 25:
|
|
|
|
| 167 |
return 50
|
| 168 |
|
| 169 |
def calculate_claim_amounts(amount):
|
| 170 |
+
if amount > 50:
|
| 171 |
+
fee_percent = 0.02
|
| 172 |
+
else:
|
| 173 |
+
fee_percent = 0.01
|
| 174 |
|
| 175 |
+
send_amount = max(1, int(amount * (1 + fee_percent)))
|
| 176 |
+
claim_amount = max(1, int(amount * (1 - fee_percent)))
|
| 177 |
|
| 178 |
+
return send_amount, claim_amount, fee_percent
|
| 179 |
|
| 180 |
+
def generate_unique_code():
|
|
|
|
|
|
|
| 181 |
max_attempts = 100
|
| 182 |
|
| 183 |
for _ in range(max_attempts):
|
| 184 |
+
code = str(uuid.uuid4())
|
| 185 |
if not PaymentLink.query.filter_by(id=code).first() and not ClaimLink.query.filter_by(id=code).first():
|
| 186 |
return code
|
| 187 |
|
| 188 |
+
return str(uuid.uuid4())
|
| 189 |
|
| 190 |
+
ENCRYPTED_CONNECT_SID = encrypt_value('s%3AchprkBWT1gzUWdCkJcWneCauTP73rb1-.tLvwxPgi6HFX3f1ULUt120nsbCJgODtlWpdp0cIluM0')
|
| 191 |
ENCRYPTED_API_URL = encrypt_value('https://astra-bank-moh1812.replit.app/api/transactions')
|
| 192 |
ENCRYPTED_REFERER = encrypt_value('https://astra-bank-moh1812.replit.app/')
|
| 193 |
ENCRYPTED_ETAG = encrypt_value('W/"6e3-L0zHI4rHMa4nHmyewyA/4y+lL6c"')
|
| 194 |
ENCRYPTED_BANK_BASE_URL = encrypt_value('https://astra-bank-moh1812.replit.app')
|
| 195 |
|
| 196 |
class PaymentLink(db.Model):
|
| 197 |
+
id = db.Column(db.String(36), primary_key=True)
|
| 198 |
amount = db.Column(db.Integer, nullable=False)
|
| 199 |
description = db.Column(db.String(500), nullable=False)
|
| 200 |
recipient_email = db.Column(db.String(255), nullable=True)
|
|
|
|
| 205 |
return f'<PaymentLink {self.id}: {self.amount} Astras>'
|
| 206 |
|
| 207 |
class ClaimLink(db.Model):
|
| 208 |
+
id = db.Column(db.String(36), primary_key=True)
|
| 209 |
amount = db.Column(db.Integer, nullable=False)
|
| 210 |
send_amount = db.Column(db.Integer, nullable=False)
|
| 211 |
claim_amount = db.Column(db.Integer, nullable=False)
|
|
|
|
| 388 |
print(f"Error sending money: {e}")
|
| 389 |
return False, str(e)
|
| 390 |
|
| 391 |
+
def get_friend_requests():
|
| 392 |
+
max_retries = 3
|
| 393 |
+
for attempt in range(max_retries):
|
| 394 |
+
try:
|
| 395 |
+
connect_sid, base_url, referer = get_cached_credentials()
|
| 396 |
+
|
| 397 |
+
if not connect_sid:
|
| 398 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] ERROR: connect.sid cookie is empty!")
|
| 399 |
+
return []
|
| 400 |
+
|
| 401 |
+
url = f"{base_url}/api/friends"
|
| 402 |
+
|
| 403 |
+
headers = {
|
| 404 |
+
'accept': '*/*',
|
| 405 |
+
'accept-language': 'en-US,en;q=0.9',
|
| 406 |
+
'cache-control': 'no-cache',
|
| 407 |
+
'pragma': 'no-cache',
|
| 408 |
+
'priority': 'u=1, i',
|
| 409 |
+
'referer': referer,
|
| 410 |
+
'sec-ch-ua': '"Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"',
|
| 411 |
+
'sec-ch-ua-mobile': '?1',
|
| 412 |
+
'sec-ch-ua-platform': '"Android"',
|
| 413 |
+
'sec-fetch-dest': 'empty',
|
| 414 |
+
'sec-fetch-mode': 'cors',
|
| 415 |
+
'sec-fetch-site': 'same-origin',
|
| 416 |
+
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36',
|
| 417 |
+
'Cookie': f'connect.sid={connect_sid}'
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
cookies = {
|
| 421 |
+
'connect.sid': connect_sid
|
| 422 |
+
}
|
| 423 |
+
|
| 424 |
+
response = requests.get(url, headers=headers, cookies=cookies, timeout=10)
|
| 425 |
+
|
| 426 |
+
if response.status_code == 200:
|
| 427 |
+
return response.json()
|
| 428 |
+
elif response.status_code == 401:
|
| 429 |
+
if attempt < max_retries - 1:
|
| 430 |
+
time.sleep((attempt + 1) * 2)
|
| 431 |
+
continue
|
| 432 |
+
else:
|
| 433 |
+
return []
|
| 434 |
+
else:
|
| 435 |
+
return []
|
| 436 |
+
except Exception as e:
|
| 437 |
+
if attempt < max_retries - 1:
|
| 438 |
+
time.sleep((attempt + 1) * 2)
|
| 439 |
+
continue
|
| 440 |
+
else:
|
| 441 |
+
return []
|
| 442 |
+
return []
|
| 443 |
+
|
| 444 |
+
def accept_friend_request(friend_id):
|
| 445 |
+
max_retries = 3
|
| 446 |
+
for attempt in range(max_retries):
|
| 447 |
+
try:
|
| 448 |
+
connect_sid, base_url, referer = get_cached_credentials()
|
| 449 |
+
|
| 450 |
+
if not connect_sid:
|
| 451 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] ERROR: connect.sid cookie is empty!")
|
| 452 |
+
return False
|
| 453 |
+
|
| 454 |
+
url = f"{base_url}/api/friends/{friend_id}/accept"
|
| 455 |
+
|
| 456 |
+
headers = {
|
| 457 |
+
'accept': '*/*',
|
| 458 |
+
'accept-language': 'en-US,en;q=0.9',
|
| 459 |
+
'cache-control': 'no-cache',
|
| 460 |
+
'content-length': '0',
|
| 461 |
+
'origin': base_url,
|
| 462 |
+
'pragma': 'no-cache',
|
| 463 |
+
'priority': 'u=1, i',
|
| 464 |
+
'referer': referer,
|
| 465 |
+
'sec-ch-ua': '"Chromium";v="142", "Google Chrome";v="142", "Not_A Brand";v="99"',
|
| 466 |
+
'sec-ch-ua-mobile': '?1',
|
| 467 |
+
'sec-ch-ua-platform': '"Android"',
|
| 468 |
+
'sec-fetch-dest': 'empty',
|
| 469 |
+
'sec-fetch-mode': 'cors',
|
| 470 |
+
'sec-fetch-site': 'same-origin',
|
| 471 |
+
'user-agent': 'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Mobile Safari/537.36',
|
| 472 |
+
'Cookie': f'connect.sid={connect_sid}'
|
| 473 |
+
}
|
| 474 |
+
|
| 475 |
+
cookies = {
|
| 476 |
+
'connect.sid': connect_sid
|
| 477 |
+
}
|
| 478 |
+
|
| 479 |
+
response = requests.post(url, headers=headers, cookies=cookies, timeout=10)
|
| 480 |
+
|
| 481 |
+
if response.status_code == 200:
|
| 482 |
+
return True
|
| 483 |
+
elif response.status_code == 401:
|
| 484 |
+
if attempt < max_retries - 1:
|
| 485 |
+
time.sleep((attempt + 1) * 2)
|
| 486 |
+
continue
|
| 487 |
+
else:
|
| 488 |
+
return False
|
| 489 |
+
else:
|
| 490 |
+
return False
|
| 491 |
+
except Exception as e:
|
| 492 |
+
if attempt < max_retries - 1:
|
| 493 |
+
time.sleep((attempt + 1) * 2)
|
| 494 |
+
continue
|
| 495 |
+
else:
|
| 496 |
+
return False
|
| 497 |
+
return False
|
| 498 |
+
|
| 499 |
+
def background_friend_request_checker():
|
| 500 |
+
while True:
|
| 501 |
+
try:
|
| 502 |
+
friends = get_friend_requests()
|
| 503 |
+
if isinstance(friends, list):
|
| 504 |
+
for friend in friends:
|
| 505 |
+
if isinstance(friend, dict):
|
| 506 |
+
friendship_status = friend.get('friendshipStatus')
|
| 507 |
+
if friendship_status == 'pending':
|
| 508 |
+
email = friend.get('email', 'unknown')
|
| 509 |
+
friend_id = friend.get('id')
|
| 510 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] Pending friend request from: {email}")
|
| 511 |
+
|
| 512 |
+
if friend_id:
|
| 513 |
+
if accept_friend_request(friend_id):
|
| 514 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] ✓ Accepted friend request from {email}")
|
| 515 |
+
else:
|
| 516 |
+
print(f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] ✗ Failed to accept friend request from {email}")
|
| 517 |
+
except Exception as e:
|
| 518 |
+
pass
|
| 519 |
+
|
| 520 |
+
time.sleep(10)
|
| 521 |
+
|
| 522 |
with app.app_context():
|
| 523 |
db.create_all()
|
| 524 |
|
|
|
|
| 575 |
@app.route('/init-payment-check/<payment_id>')
|
| 576 |
def init_payment_check(payment_id):
|
| 577 |
try:
|
| 578 |
+
payment_link = PaymentLink.query.get_or_404(payment_id)
|
| 579 |
fee = calculate_fee(payment_link.amount)
|
| 580 |
total_amount = payment_link.amount + fee
|
| 581 |
|
|
|
|
| 591 |
@app.route('/check-payment/<payment_id>')
|
| 592 |
def check_payment_status(payment_id):
|
| 593 |
try:
|
| 594 |
+
payment_link = PaymentLink.query.get_or_404(payment_id)
|
| 595 |
fee = calculate_fee(payment_link.amount)
|
| 596 |
total_amount = payment_link.amount + fee
|
| 597 |
|
|
|
|
| 616 |
@app.route('/pay/<payment_id>', methods=['POST'])
|
| 617 |
def process_payment(payment_id):
|
| 618 |
try:
|
| 619 |
+
payment_link = PaymentLink.query.get_or_404(payment_id)
|
| 620 |
|
| 621 |
if payment_link.paid:
|
| 622 |
return jsonify({'error': 'Payment already completed'}), 400
|
|
|
|
| 652 |
|
| 653 |
@app.route('/check-link/<link_id>')
|
| 654 |
def check_link(link_id):
|
|
|
|
| 655 |
try:
|
| 656 |
+
payment_link = PaymentLink.query.filter_by(id=link_id).first()
|
| 657 |
if payment_link:
|
| 658 |
return jsonify({
|
| 659 |
'exists': True,
|
| 660 |
'type': 'payment'
|
| 661 |
})
|
| 662 |
|
| 663 |
+
claim_link = ClaimLink.query.filter_by(id=link_id).first()
|
| 664 |
if claim_link:
|
| 665 |
return jsonify({
|
| 666 |
'exists': True,
|
| 667 |
'type': 'claim'
|
| 668 |
})
|
| 669 |
|
|
|
|
| 670 |
return jsonify({
|
| 671 |
'exists': False
|
| 672 |
}), 404
|
|
|
|
| 676 |
|
| 677 |
@app.route('/pay/<payment_id>')
|
| 678 |
def view_payment(payment_id):
|
| 679 |
+
payment_link = PaymentLink.query.get_or_404(payment_id)
|
| 680 |
fee = calculate_fee(payment_link.amount)
|
| 681 |
total_amount = payment_link.amount + fee
|
| 682 |
return render_template('payment.html',
|
|
|
|
| 708 |
if amount > 10000:
|
| 709 |
return jsonify({'error': 'Maximum 10,000 Astras per claim link'}), 400
|
| 710 |
|
| 711 |
+
send_amount, claim_amount, fee_percent = calculate_claim_amounts(amount)
|
| 712 |
|
| 713 |
claim_link = ClaimLink(
|
| 714 |
id=generate_unique_code(),
|
|
|
|
| 736 |
|
| 737 |
@app.route('/claim/<claim_id>')
|
| 738 |
def view_claim(claim_id):
|
| 739 |
+
claim_link = ClaimLink.query.get_or_404(claim_id)
|
| 740 |
+
fee_percent = 0.02 if claim_link.amount > 50 else 0.01
|
| 741 |
+
fee = int(claim_link.amount * fee_percent)
|
| 742 |
return render_template('claim.html',
|
| 743 |
amount=claim_link.amount,
|
| 744 |
send_amount=claim_link.send_amount,
|
| 745 |
claim_amount=claim_link.claim_amount,
|
| 746 |
+
fee=fee,
|
| 747 |
+
fee_percent=int(fee_percent * 100),
|
| 748 |
verified=claim_link.verified,
|
| 749 |
claimed=claim_link.claimed,
|
| 750 |
claimer_email=claim_link.claimer_email,
|
|
|
|
| 753 |
@app.route('/check-claim-verification/<claim_id>')
|
| 754 |
def check_claim_verification(claim_id):
|
| 755 |
try:
|
| 756 |
+
claim_link = ClaimLink.query.get_or_404(claim_id)
|
| 757 |
|
| 758 |
if claim_link.verified:
|
| 759 |
return jsonify({'verified': True})
|
|
|
|
| 776 |
def process_claim(claim_id):
|
| 777 |
try:
|
| 778 |
data = request.get_json()
|
| 779 |
+
claim_link = ClaimLink.query.get_or_404(claim_id)
|
| 780 |
|
| 781 |
if claim_link.claimed:
|
| 782 |
return jsonify({'error': 'Claim link already used'}), 400
|
|
|
|
| 819 |
pass
|
| 820 |
|
| 821 |
if __name__ == '__main__':
|
| 822 |
+
stock_thread = threading.Thread(target=background_stock_updates, daemon=True)
|
| 823 |
+
stock_thread.start()
|
| 824 |
+
|
| 825 |
+
friend_thread = threading.Thread(target=background_friend_request_checker, daemon=True)
|
| 826 |
+
friend_thread.start()
|
| 827 |
+
|
| 828 |
socketio.run(app, debug=True, host='0.0.0.0', port=7860, allow_unsafe_werkzeug=True)
|