From 3b8d025f5737e83c993fb934bfaaa602349a9f59 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sun, 18 Sep 2022 02:28:09 +0200 Subject: [PATCH] fix kofi --- files/classes/transactions.py | 1 + files/routes/users.py | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/files/classes/transactions.py b/files/classes/transactions.py index 6030d98978..c5b5092446 100644 --- a/files/classes/transactions.py +++ b/files/classes/transactions.py @@ -12,6 +12,7 @@ if KOFI_TOKEN: type = Column(String) amount = Column(Integer) email = Column(String) + claimed = Column(Boolean) def __repr__(self): return f"" \ No newline at end of file diff --git a/files/routes/users.py b/files/routes/users.py index dde3ca048c..d90f9a7d89 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -1422,11 +1422,10 @@ def settings_kofi(v): if not transaction: return {"error": "Email not found"}, 404 - tier = kofi_tiers[transaction.amount] - if v.patron == tier: return {"error": f"{patron} rewards already claimed"}, 400 + if transaction.claimed: + return {"error": f"{patron} rewards already claimed"}, 400 - existing = g.db.query(User.id).filter(User.email == v.email, User.is_activated == True, User.patron >= tier).first() - if existing: return {"error": f"{patron} rewards already claimed on another account"}, 400 + tier = kofi_tiers[transaction.amount] v.patron = tier if v.discord_id: add_role(v, f"{tier}") @@ -1439,6 +1438,9 @@ def settings_kofi(v): g.db.add(v) badge_grant(badge_id=20+tier, user=v) - + + transaction.claimed = True + + g.db.add(transaction) return {"message": f"{patron} rewards claimed!"} \ No newline at end of file