From ea70b691947e7b32689e15ad8ee5636be5c35aab Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Sat, 28 Aug 2021 00:10:03 +0200 Subject: [PATCH] fdfd --- docker-compose.yml | 1 + files/classes/user.py | 4 ++- files/routes/front.py | 6 ++-- files/routes/posts.py | 69 ++++++++++++++++++++++--------------------- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index cab256e6a..1b53ceeb8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -37,6 +37,7 @@ services: - READ_ONLY=0 - BOT_DISABLE=0 - COINS_NAME=Dramacoins + - DEFAULT_TIME_FILTER=day - DEFAULT_THEME=dark - DEFAULT_COLOR=ff66ac #YOU HAVE TO PICK ONE OF THOSE COLORS OR SHIT WILL BREAK: ff66ac, 805ad5, 62ca56, 38a169, 80ffff, 2a96f3, eb4963, ff0000, f39731, 30409f, 3e98a7, e4432d, 7b9ae4, ec72de, 7f8fa6, f8db58 - SLOGAN=Dude bussy lmao diff --git a/files/classes/user.py b/files/classes/user.py index 8fd51f34d..1eaf667fe 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -19,6 +19,8 @@ from files.helpers.security import * site = environ.get("DOMAIN").strip() defaulttheme = environ.get("DEFAULT_THEME", "light").strip() defaultcolor = environ.get("DEFAULT_COLOR", "fff").strip() +defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "day").strip() + class User(Base, Stndrd, Age_times): __tablename__ = "users" id = Column(Integer, primary_key=True) @@ -86,7 +88,7 @@ class User(Base, Stndrd, Age_times): stored_subscriber_count = Column(Integer, default=0) defaultsortingcomments = Column(String, default="top") defaultsorting = Column(String, default="hot") - defaulttime = Column(String, default="day") + defaulttime = Column(String, default=defaulttimefilter) is_nofollow = Column(Boolean, default=False) custom_filter_list = Column(String(1000)) diff --git a/files/routes/front.py b/files/routes/front.py index 025f06f53..fdf29a88e 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -4,6 +4,8 @@ from files.helpers.get import * from files.__main__ import app, cache from files.classes.submission import Submission +defaulttimefilter = environ.get("DEFAULT_TIME_FILTER", "day").strip() + @app.get("/post/") def slash_post(): return redirect("/") @@ -207,7 +209,7 @@ def front_all(v): defaulttime = v.defaulttime else: defaultsorting = "hot" - defaulttime = "day" + defaulttime = defaulttimefilter sort=request.args.get("sort", defaultsorting) t=request.args.get('t', defaulttime) @@ -409,7 +411,7 @@ def all_comments(v): page = int(request.args.get("page", 1)) sort=request.args.get("sort", "new") - t=request.args.get("t", "day") + t=request.args.get("t", defaulttimefilter) idlist = comment_idlist(v=v, page=page, diff --git a/files/routes/posts.py b/files/routes/posts.py index de0c4d262..379c73ded 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -871,41 +871,42 @@ def submit_post(v): n = Notification(comment_id=c_jannied.id, user_id=v.id) g.db.add(n) - c = Comment(author_id=261, - distinguish_level=6, - parent_submission=new_post.id, - level=1, - over_18=False, - is_bot=True, - app_id=None, + if "rdrama" in request.host or new_post.url: + c = Comment(author_id=261, + distinguish_level=6, + parent_submission=new_post.id, + level=1, + over_18=False, + is_bot=True, + app_id=None, + ) + + g.db.add(c) + g.db.flush() + + new_post.comment_count = 1 + g.db.add(new_post) + + if "rdrama" in request.host: + if v.id == 995: body = "fuck off carp" + else: body = random.choice(snappyquotes) + body += "\n\n---\n\n" + else: body = "" + if new_post.url: + body += f"Snapshots:\n\n* [reveddit.com](https://reveddit.com/{new_post.url})\n* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={urllib.parse.quote(new_post.url)}&run=1) (click to archive)" + gevent.spawn(archiveorg, new_post.url) + with CustomRenderer(post_id=new_post.id) as renderer: body_md = renderer.render(mistletoe.Document(body)) + body_html = sanitize(body_md) + c_aux = CommentAux( + id=c.id, + body_html=body_html, + body=body ) - - g.db.add(c) - g.db.flush() - - new_post.comment_count = g.db.query(Comment).filter_by(parent_submission=new_post.id).count() - g.db.add(new_post) - - if "rdrama" in request.host: - if v.id == 995: body = "fuck off carp" - else: body = random.choice(snappyquotes) - body += "\n\n---\n\n" - else: body = "" - if new_post.url: - body += f"Snapshots:\n\n* [reveddit.com](https://reveddit.com/{new_post.url})\n* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={urllib.parse.quote(new_post.url)}&run=1) (click to archive)" - gevent.spawn(archiveorg, new_post.url) - with CustomRenderer(post_id=new_post.id) as renderer: body_md = renderer.render(mistletoe.Document(body)) - body_html = sanitize(body_md) - c_aux = CommentAux( - id=c.id, - body_html=body_html, - body=body - ) - g.db.add(c_aux) - g.db.flush() - n = Notification(comment_id=c.id, user_id=v.id) - g.db.add(n) - g.db.flush() + g.db.add(c_aux) + g.db.flush() + n = Notification(comment_id=c.id, user_id=v.id) + g.db.add(n) + g.db.flush() v.post_count = v.submissions.filter_by(is_banned=False, deleted_utc=0).count() g.db.add(v)