diff --git a/drama/classes/user.py b/drama/classes/user.py index 414d0df88..a7784a0c6 100644 --- a/drama/classes/user.py +++ b/drama/classes/user.py @@ -38,6 +38,7 @@ class User(Base, Stndrd, Age_times): passhash = deferred(Column(String, default=None)) banawards = Column(Integer, default=0) created_utc = Column(Integer, default=0) + suicide_utc = Column(Integer, default=0) admin_level = Column(Integer, default=0) resized = Column(Boolean, default=True) agendaposter = Column(Boolean, default=False) diff --git a/drama/routes/posts.py b/drama/routes/posts.py index 3bab0530b..b349eef96 100644 --- a/drama/routes/posts.py +++ b/drama/routes/posts.py @@ -1,7 +1,6 @@ from urllib.parse import urlparse import mistletoe import urllib.parse -import threading import gevent from drama.helpers.wrappers import * @@ -23,7 +22,8 @@ from PIL import Image as PILimage with open("snappy.txt", "r") as f: snappyquotes = f.read().split("{[para]}") -def resize(): +@app.route("/resize") +def resize() u = g.db.query(User).filter(User.profileurl != None, User.resized != True).first() print(u.username) print(f"1 {u.profileurl}") @@ -44,7 +44,6 @@ def resize(): g.db.add(u) print(f"2 {u.profileurl}") - @app.route("/banaward/post/") @auth_required def postbanaward(post_id, v): @@ -95,8 +94,6 @@ def submit_get(v): if v and v.is_banned and not v.unban_utc: return render_template("seized.html") b = get_guild("general") - - resize() return render_template("submit.html", v=v, diff --git a/drama/routes/users.py b/drama/routes/users.py index 12bb50df1..314504aa0 100644 --- a/drama/routes/users.py +++ b/drama/routes/users.py @@ -1,6 +1,7 @@ import qrcode import io from datetime import datetime +from time import time from drama.classes.user import ViewerRelationship from drama.helpers.alerts import * @@ -21,6 +22,8 @@ beams_client = PushNotifications( @app.route("/@/suicide") @auth_required def suicide(v, username): + t = int(time()) + if t - v.suicide_utc < 86400: abort(403) user = get_user(username) suicide = f"""Hi there, @@ -41,6 +44,8 @@ def suicide(v, username): Your fellow dramatards care about you and there are people who want to help.""" send_notification(1046, user, suicide) + v.suicide_utc = t + g.db.add(v) return "", 204 @app.route("/api/v1/user/", methods=["GET"])