From 7fadf2d7ba93261e822985ad497d7c85bc5a77a2 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Fri, 4 Feb 2022 16:49:27 +0200 Subject: [PATCH] xvc --- files/classes/submission.py | 1 + files/routes/front.py | 12 +++++++++--- files/routes/posts.py | 12 +++++++----- files/templates/home.html | 2 +- files/templates/submit.html | 2 +- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/files/classes/submission.py b/files/classes/submission.py index 285883812..7d86d1745 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -29,6 +29,7 @@ class Submission(Base): distinguish_level = Column(Integer, default=0) stickied = Column(String) stickied_utc = Column(Integer) + hole = Column(String) is_pinned = Column(Boolean, default=False) private = Column(Boolean, default=False) club = Column(Boolean, default=False) diff --git a/files/routes/front.py b/files/routes/front.py index 6de324b95..011083418 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -128,9 +128,11 @@ def notifications(v): @app.get("/") @app.get("/logged_out") +@app.get("/") +@app.get("/logged_out/") @limiter.limit("3/second;30/minute;400/hour;2000/day") @auth_desired -def front_all(v): +def front_all(v, hole=None): if g.webview and not session.get("session_id"): session.permanent = True session["session_id"] = secrets.token_hex(49) @@ -162,6 +164,7 @@ def front_all(v): filter_words=v.filter_words if v else [], gt=int(request.values.get("utc_greater_than", 0)), lt=int(request.values.get("utc_less_than", 0)), + hole=hole ) posts = get_posts(ids, v=v) @@ -243,15 +246,18 @@ def front_all(v): g.db.commit() if request.headers.get("Authorization"): return {"data": [x.json for x in posts], "next_exists": next_exists} - return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode) + return render_template("home.html", v=v, listing=posts, next_exists=next_exists, sort=sort, t=t, page=page, ccmode=ccmode, hole=hole) @cache.memoize(timeout=86400) -def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=None, lt=None): +def frontlist(v=None, sort="hot", page=1, t="all", ids_only=True, ccmode="false", filter_words='', gt=None, lt=None, hole=None): posts = g.db.query(Submission) + if hole: posts = posts.filter_by(hole=hole) + else: posts = posts.filter_by(hole=None) + if t == 'all': cutoff = 0 else: now = int(time.time()) diff --git a/files/routes/posts.py b/files/routes/posts.py index c6d27cd1d..e507f510f 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -88,10 +88,10 @@ def publish(pid, v): return {"message": "Post published!"} @app.get("/submit") +@app.get("/submit/") @auth_required -def submit_get(v): - return render_template("submit.html", - v=v) +def submit_get(v, hole=None): + return render_template("submit.html", v=v, hole=hole) @app.get("/post/") @app.get("/post//") @@ -751,9 +751,10 @@ def thumbnail_thread(pid): @app.post("/submit") +@app.post("/submit/") @limiter.limit("1/second;6/minute;200/hour;1000/day") @auth_required -def submit_post(v): +def submit_post(v, hole=None): if v.is_suspended: return {"error": "You can't perform this action while banned."}, 403 if v and v.patron: @@ -1006,7 +1007,8 @@ def submit_post(v): embed_url=embed, title=title[:500], title_html=title_html, - created_utc=int(time.time()) + created_utc=int(time.time()), + hole=hole ) g.db.add(new_post) diff --git a/files/templates/home.html b/files/templates/home.html index ff0508c49..0539fc85e 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -114,7 +114,7 @@