diff --git a/files/classes/user.py b/files/classes/user.py index a90160d60..16577ed30 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -46,6 +46,7 @@ class User(Base): profileurl = Column(String) bannerurl = Column(String) patron = Column(Integer, default=0) + patron_utc = Column(Integer, default=0) verified = Column(String) verifiedcolor = Column(String) marseyawarded = Column(Integer) diff --git a/files/routes/admin.py b/files/routes/admin.py index 7cef81402..08045f077 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -211,7 +211,7 @@ def monthly(v): emails = [x['email'] for x in requests.get(f'https://api.gumroad.com/v2/products/{GUMROAD_ID}/subscribers', data=data, timeout=5).json()["subscribers"]] - for u in g.db.query(User).filter(User.patron > 0).all(): + for u in g.db.query(User).filter(User.patron > 0, User.patron_utc == 0).all(): if u.email and u.email.lower() in emails: if u.patron == 1: procoins = 2500 elif u.patron == 2: procoins = 5000 diff --git a/files/routes/awards.py b/files/routes/awards.py index 39489d99a..84b4fecd0 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -390,6 +390,7 @@ def award_post(pid, v): send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "benefactor": author.patron = 1 + author.patron_utc += int(time.time()) + 2629746 author.procoins += 2500 if not v.has_badge(103): badge = Badge(user_id=v.id, badge_id=103) @@ -611,6 +612,7 @@ def award_comment(cid, v): send_notification(author.id, f"@AutoJanny has given you the following profile badge:\n\n![]({badge.path})\n\n{badge.name}") elif kind == "benefactor": author.patron = 1 + author.patron_utc += int(time.time()) + 2629746 author.procoins += 2500 if not v.has_badge(103): badge = Badge(user_id=v.id, badge_id=103) diff --git a/files/routes/front.py b/files/routes/front.py index 32415b274..f9128a50e 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -168,6 +168,13 @@ def front_all(v): posts = get_posts(ids, v=v) if v: + if v.patron_utc and v.patron_utc < time.time(): + v.patron = 0 + v.patron_utc = 0 + send_repeatable_notification(v.id, "Your paypig status has expired!") + g.db.add(v) + g.db.commit() + if v.unban_utc and v.unban_utc < time.time(): v.is_banned = 0 v.unban_utc = 0