From da2af7f8fa8bfb06648eacf9f950e3cabc9f623a Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Thu, 18 Nov 2021 16:21:19 +0200 Subject: [PATCH] fdsfsd --- files/__main__.py | 2 +- files/classes/comment.py | 8 +++---- files/classes/submission.py | 4 ++-- files/classes/user.py | 4 ++-- files/helpers/alerts.py | 12 +++++------ files/helpers/const.py | 40 ++++++++++++++++++----------------- files/routes/admin.py | 4 ++-- files/routes/awards.py | 4 ++-- files/routes/comments.py | 36 +++++++++++++++---------------- files/routes/front.py | 4 ++-- files/routes/oauth.py | 2 +- files/routes/posts.py | 26 +++++++++++------------ files/routes/settings.py | 6 +++--- files/templates/comments.html | 6 +++--- 14 files changed, 80 insertions(+), 78 deletions(-) diff --git a/files/__main__.py b/files/__main__.py index 2cd233d96..899b23eaa 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -73,7 +73,7 @@ r=redis.Redis(host=environ.get("REDIS_URL", "redis://127.0.0.1"), decode_respon limiter = Limiter( app, key_func=get_ipaddr, - default_limits=["50/minute"], + default_limits=["3/second;30/minute;100/hour"], headers_enabled=True, strategy="fixed-window" ) diff --git a/files/classes/comment.py b/files/classes/comment.py index 2b5fc3d47..d0bdf5bfb 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -7,7 +7,7 @@ from sqlalchemy import * from sqlalchemy.orm import relationship from files.__main__ import Base from files.classes.votes import CommentVote -from files.helpers.const import AUTOPOLLER_ACCOUNT, censor_slurs +from files.helpers.const import AUTOPOLLER_ID, censor_slurs from files.helpers.lazy import lazy from .flags import CommentFlag from random import randint @@ -80,7 +80,7 @@ class Comment(Base): @property @lazy def options(self): - return [x for x in self.child_comments if x.author_id == AUTOPOLLER_ACCOUNT] + return [x for x in self.child_comments if x.author_id == AUTOPOLLER_ID] def total_poll_voted(self, v): if v: @@ -185,7 +185,7 @@ class Comment(Base): def replies(self): r = self.__dict__.get("replies", None) if r: r = [x for x in r if not x.author.shadowbanned] - if not r and r != []: r = sorted([x for x in self.child_comments if not x.author.shadowbanned and x.author_id != AUTOPOLLER_ACCOUNT], key=lambda x: x.score, reverse=True) + if not r and r != []: r = sorted([x for x in self.child_comments if not x.author.shadowbanned and x.author_id != AUTOPOLLER_ID], key=lambda x: x.score, reverse=True) return r @replies.setter @@ -203,7 +203,7 @@ class Comment(Base): @property def replies3(self): r = self.__dict__.get("replies", None) - if not r and r != []: r = sorted([x for x in self.child_comments if x.author_id != AUTOPOLLER_ACCOUNT], key=lambda x: x.score, reverse=True) + if not r and r != []: r = sorted([x for x in self.child_comments if x.author_id != AUTOPOLLER_ID], key=lambda x: x.score, reverse=True) return r @property diff --git a/files/classes/submission.py b/files/classes/submission.py index 003d4be6d..9a9dc5a44 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -7,7 +7,7 @@ from flask import render_template from sqlalchemy import * from sqlalchemy.orm import relationship from files.__main__ import Base -from files.helpers.const import AUTOPOLLER_ACCOUNT, censor_slurs, TROLLTITLES +from files.helpers.const import AUTOPOLLER_ID, censor_slurs, TROLLTITLES from files.helpers.lazy import lazy from .flags import Flag from .comment import Comment @@ -80,7 +80,7 @@ class Submission(Base): @property @lazy def options(self): - return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOPOLLER_ACCOUNT, level=1) + return g.db.query(Comment).filter_by(parent_submission = self.id, author_id = AUTOPOLLER_ID, level=1) def total_poll_voted(self, v): if v: diff --git a/files/classes/user.py b/files/classes/user.py index 9ccf12649..ce2c5d66e 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -355,7 +355,7 @@ class User(Base): @property @lazy def post_notifications_count(self): - return g.db.query(Notification.id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.author_id == AUTOJANNY_ACCOUNT).count() + return g.db.query(Notification.id).join(Comment).filter(Notification.user_id == self.id, Notification.read == False, Comment.author_id == AUTOJANNY_ID).count() @property @@ -463,7 +463,7 @@ class User(Base): self.profileurl = None if self.discord_id: remove_user(self) - self.is_banned = admin.id if admin else AUTOJANNY_ACCOUNT + self.is_banned = admin.id if admin else AUTOJANNY_ID if reason: self.ban_reason = reason g.db.add(self) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index ef1335d9a..19e70350a 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -14,8 +14,8 @@ def send_notification(uid, text, autojanny=False): text_html = sanitize(text_html) - if autojanny: author_id = AUTOJANNY_ACCOUNT - else: author_id = NOTIFICATIONS_ACCOUNT + if autojanny: author_id = AUTOJANNY_ID + else: author_id = NOTIFICATIONS_ID new_comment = Comment(author_id=author_id, parent_submission=None, @@ -38,7 +38,7 @@ def send_follow_notif(vid, user, text): text_html = CustomRenderer().render(mistletoe.Document(text)) text_html = sanitize(text_html) - new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT, + new_comment = Comment(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body=text, @@ -57,7 +57,7 @@ def send_unfollow_notif(vid, user, text): text_html = CustomRenderer().render(mistletoe.Document(text)) text_html = sanitize(text_html) - new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT, + new_comment = Comment(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body=text, @@ -76,7 +76,7 @@ def send_block_notif(vid, user, text): text_html = CustomRenderer().render(mistletoe.Document(text)) text_html = sanitize(text_html) - new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT, + new_comment = Comment(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body=text, @@ -95,7 +95,7 @@ def send_unblock_notif(vid, user, text): text_html = CustomRenderer().render(mistletoe.Document(text)) text_html = sanitize(text_html) - new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT, + new_comment = Comment(author_id=NOTIFICATIONS_ID, parent_submission=None, distinguish_level=6, body=text, diff --git a/files/helpers/const.py b/files/helpers/const.py index 87f9d4bd7..6c8cf397b 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -95,12 +95,13 @@ Thank you.""" WELCOME_MSG = "Hi there! It's me, your soon-to-be favorite rDrama user @carpathianflorist here to give you a brief rundown on some of the sick features we have here. You'll probably want to start by following me, though. So go ahead and click my name and then smash that Follow button. This is actually really important, so go on. Hurry.\n\nThanks!\n\nNext up: If you're a member of the media, similarly just shoot me a DM and I'll set about verifying you and then we can take care of your sad journalism stuff.\n\n**FOR EVERYONE ELSE**\n\nYou'll probably want to start by navigating to [the settings page](https://rdrama.net/settings/profile) (we'll be prettying this up so it's less convoluted soon, don't worry) and getting some basic customization done.\n\n### Themes\n\nDefinitely change your theme right away, the default one (Midnight) is pretty enough, but why not use something *exotic* like Win98, or *flashy* like Tron? Even Coffee is super tasteful and way more fun than the default. More themes to come when we get around to it!\n\n### Avatar/pfp\n\nYou'll want to set this pretty soon; without uploading one, I put together a randomly-assigned selection of 180ish pictures of furries, ugly goths, mujahideen, anime girls, and My Little Ponys which are used by everyone who was too lazy to set a pfp. Set the banner too while you're at it. Your profile is important!\n\n### Flairs\n\nSince you're already on the settings page, you may as well set a flair, too. As with your username, you can - obviously - choose the color of this, either with a hex value or just from the preset colors. And also like your username, you can change this at any time. [Paypigs](https://marsey1.gumroad.com/l/tfcvri) can even further relive the glory days of 90s-00s internet and set obnoxious signatures.\n\n### PROFILE ANTHEMS\n\nSpeaking of profiles, hey, remember MySpace? Do you miss autoplaying music assaulting your ears every time you visited a friend's page? Yeah, we brought that back. Enter a YouTube URL, wait a few seconds for it to process, and then BAM! you've got a profile anthem which people cannot mute. Unless they spend 20,000 dramacoin in the shop for a mute button. Which you can then remove from your profile buy spending 40,000 dramacoin on an unmuteable anthem. Get fucked poors!\n\n### Dramacoin?\n\nDramacoin is basically our take on the karma system. Except unlike the karma system, it's not gay and boring and stupid and useless. Dramacoin can be spent at [Marsey's Dramacoin Emporium](https://rdrama.net/shop) on upgrades to your user experience (many more coming than what's already listed there), and best of all on tremendously annoying awards to fuck with your fellow dramautists. We're always adding more, so check back regularly in case you happen to miss one of the announcement posts. Holiday-themed awards are currently unavailable while we resolve an internal dispute, but they **will** return, no matter what some other janitors insist.\n\nLike karma, dramacoin is obtained by getting upvotes on your threads and comments. *Unlike* karma, it's also obtained by getting downvotes on your threads and comments. Downvotes don't really do anything here - they pay the same amount of dramacoin and they increase thread/comment ranking just the same as an upvote. You just use them to express petty disapproval and hopefully start a fight. Because all votes are visible here. To hell with your anonymity.\n\nDramacoin can also be traded amongst users from their profiles. Note that there is a 1.5% transaction fee.\n\n**Dramacoin and shop items cannot be purchased with real money and this will not change.** Though we are notoriously susceptible to bribes, so definitely shoot your shot. It'll probably go well, honestly.\n\n### Badges\n\nRemember all those neat little metallic icons you saw on my profile when you were following me? If not, scroll back up and go have a look. And doublecheck to make sure you pressed the Follow button. Anyway, those are badges. You earn them by doing a variety of things. Some of them even offer benefits, like discounts at the shop. A [complete list of badges and their requirements can be found here](https://rdrama.net/badges), though I add more pretty regularly, so keep an eye on the changelog.\n\n### Other stuff\n\nWe're always adding new features, and we take a fun-first approach to development. If you have a suggestion for something that would be fun, funny, annoying - or best of all, some combination of all three - definitely make a thread about it. Or just DM me if you're shy. Weirdo. Anyway there's also the [leaderboards](https://rdrama.net/leaderboard), boring stuff like two-factor authentication you can toggle on somewhere in the settings page (psycho), the ability to save posts and comments, close to a thousand emojis already (several hundred of which are rDrama originals), and on and on and on and on. This is just the basics, mostly to help you get acquainted with some of the things you can do here to make it more easy on the eyes, customizable, and enjoyable. If you don't enjoy it, just go away! We're not changing things to suit you! Get out of here loser! And no, you can't delete your account :na:\n\nI love you.
*xoxo Carp* 💋" if SITE == 'rdrama.net': - NOTIFICATIONS_ACCOUNT = 1046 - AUTOJANNY_ACCOUNT = 2360 - SNAPPY_ACCOUNT = 261 - LONGPOSTBOT_ACCOUNT = 1832 - ZOZBOT_ACCOUNT = 1833 - AUTOPOLLER_ACCOUNT = 6176 + BASEDBOT_ID = 0 + NOTIFICATIONS_ID = 1046 + AUTOJANNY_ID = 2360 + SNAPPY_ID = 261 + LONGPOSTBOT_ID = 1832 + ZOZBOT_ID = 1833 + AUTOPOLLER_ID = 6176 TAX_RECEIVER_ID = 747 PIZZA_SHILL_ID = 2424 CARP_ID = 995 @@ -109,13 +110,13 @@ if SITE == 'rdrama.net': LLM_ID = 253 DAD_ID = 2513 elif SITE == "pcmemes.net": - BASEDBOT_ACCOUNT = 800 - NOTIFICATIONS_ACCOUNT = 1046 - AUTOJANNY_ACCOUNT = 1050 - SNAPPY_ACCOUNT = 261 - LONGPOSTBOT_ACCOUNT = 1832 - ZOZBOT_ACCOUNT = 1833 - AUTOPOLLER_ACCOUNT = 3369 + BASEDBOT_ID = 800 + NOTIFICATIONS_ID = 1046 + AUTOJANNY_ID = 1050 + SNAPPY_ID = 261 + LONGPOSTBOT_ID = 1832 + ZOZBOT_ID = 1833 + AUTOPOLLER_ID = 3369 TAX_RECEIVER_ID = 1577 PIZZA_SHILL_ID = 0 CARP_ID = 0 @@ -124,12 +125,13 @@ elif SITE == "pcmemes.net": LLM_ID = 0 DAD_ID = 0 else: - NOTIFICATIONS_ACCOUNT = 1 - AUTOJANNY_ACCOUNT = 2 - SNAPPY_ACCOUNT = 3 - LONGPOSTBOT_ACCOUNT = 4 - ZOZBOT_ACCOUNT = 5 - AUTOPOLLER_ACCOUNT = 6 + BASEDBOT_ID = 0 + NOTIFICATIONS_ID = 1 + AUTOJANNY_ID = 2 + SNAPPY_ID = 3 + LONGPOSTBOT_ID = 4 + ZOZBOT_ID = 5 + AUTOPOLLER_ID = 6 TAX_RECEIVER_ID = 7 PIZZA_SHILL_ID = 0 CARP_ID = 0 diff --git a/files/routes/admin.py b/files/routes/admin.py index 322470ec8..47caf4368 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -997,14 +997,14 @@ def api_sticky_post(post_id, v): if post.stickied: if v.id != post.author_id: message = f"@{v.username} has pinned your [post](/post/{post_id})!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message).first() if not existing: send_notification(post.author_id, message) g.db.commit() return {"message": "Post pinned!"} else: if v.id != post.author_id: message = f"@{v.username} has unpinned your [post](/post/{post_id})!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message).first() if not existing: send_notification(post.author_id, message) g.db.commit() return {"message": "Post unpinned!"} diff --git a/files/routes/awards.py b/files/routes/awards.py index db4c1ff51..d8a8d8d00 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -426,7 +426,7 @@ def award_post(pid, v): author.ban_evade = 0 send_notification(author.id, f"You have been unbanned!") elif kind == "grass": - author.is_banned = AUTOJANNY_ACCOUNT + author.is_banned = AUTOJANNY_ID author.ban_reason = f"grass award used by @{v.username} on /post/{post.id}" link = f"[this post]({post.permalink})" send_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!") @@ -548,7 +548,7 @@ def award_comment(cid, v): author.ban_evade = 0 send_notification(author.id, f"You have been unbanned!") elif kind == "grass": - author.is_banned = AUTOJANNY_ACCOUNT + author.is_banned = AUTOJANNY_ID author.ban_reason = f"grass award used by @{v.username} on /comment/{c.id}" link = f"[this comment]({c.permalink})" send_notification(author.id, f"Your account has been suspended permanently for {link}. You must [provide the admins](/contact) a timestamped picture of you touching grass to get unbanned!") diff --git a/files/routes/comments.py b/files/routes/comments.py index 2bc10e1e6..931f3c6e3 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -96,7 +96,7 @@ def post_pid_comment_cid(cid, pid=None, anything=None, v=None): comments=comments.filter( Comment.parent_submission == post.id, - Comment.author_id != AUTOPOLLER_ACCOUNT + Comment.author_id != AUTOPOLLER_ID ).join( votes, votes.c.comment_id == Comment.id, @@ -241,7 +241,7 @@ def api_comment(v): comment.ban_reason = "AutoJanny" g.db.add(comment) ma=ModAction( - user_id=AUTOJANNY_ACCOUNT, + user_id=AUTOJANNY_ID, target_comment_id=comment.id, kind="ban_comment", _note="spam" @@ -268,7 +268,7 @@ def api_comment(v): g.db.flush() for option in options: - c_option = Comment(author_id=AUTOPOLLER_ACCOUNT, + c_option = Comment(author_id=AUTOPOLLER_ID, parent_submission=parent_submission, parent_comment_id=c.id, level=level+1, @@ -297,7 +297,7 @@ def api_comment(v): body_based_html = sanitize(body_md) - c_based = Comment(author_id=BASEDBOT_ACCOUNT, + c_based = Comment(author_id=BASEDBOT_ID, parent_submission=parent_submission, distinguish_level=6, parent_comment_id=c.id, @@ -328,7 +328,7 @@ def api_comment(v): - c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + c_jannied = Comment(author_id=AUTOJANNY_ID, parent_submission=parent_submission, distinguish_level=6, parent_comment_id=c.id, @@ -361,7 +361,7 @@ def api_comment(v): - c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + c_jannied = Comment(author_id=AUTOJANNY_ID, parent_submission=parent_submission, distinguish_level=6, parent_comment_id=c.id, @@ -396,7 +396,7 @@ def api_comment(v): - c2 = Comment(author_id=LONGPOSTBOT_ACCOUNT, + c2 = Comment(author_id=LONGPOSTBOT_ID, parent_submission=parent_submission, parent_comment_id=c.id, level=level+1, @@ -406,7 +406,7 @@ def api_comment(v): g.db.add(c2) - longpostbot = g.db.query(User).filter_by(id = LONGPOSTBOT_ACCOUNT).first() + longpostbot = g.db.query(User).filter_by(id = LONGPOSTBOT_ID).first() longpostbot.comment_count += 1 longpostbot.coins += 1 g.db.add(longpostbot) @@ -433,7 +433,7 @@ def api_comment(v): - c2 = Comment(author_id=ZOZBOT_ACCOUNT, + c2 = Comment(author_id=ZOZBOT_ID, parent_submission=parent_submission, parent_comment_id=c.id, level=level+1, @@ -459,7 +459,7 @@ def api_comment(v): - c3 = Comment(author_id=ZOZBOT_ACCOUNT, + c3 = Comment(author_id=ZOZBOT_ID, parent_submission=parent_submission, parent_comment_id=c2.id, level=level+2, @@ -481,7 +481,7 @@ def api_comment(v): body_html2 = sanitize(body_md) - c4 = Comment(author_id=ZOZBOT_ACCOUNT, + c4 = Comment(author_id=ZOZBOT_ID, parent_submission=parent_submission, parent_comment_id=c3.id, level=level+3, @@ -491,7 +491,7 @@ def api_comment(v): g.db.add(c4) - zozbot = g.db.query(User).filter_by(id = ZOZBOT_ACCOUNT).first() + zozbot = g.db.query(User).filter_by(id = ZOZBOT_ID).first() zozbot.comment_count += 3 zozbot.coins += 3 g.db.add(zozbot) @@ -512,7 +512,7 @@ def api_comment(v): for x in g.db.query(Subscription.user_id).filter_by(submission_id=c.parent_submission).all(): notify_users.add(x[0]) - if parent.author.id != v.id: notify_users.add(parent.author.id) + if parent.author.id not in [v.id, BASEDBOT_ID, AUTOJANNY_ID, SNAPPY_ID, LONGPOSTBOT_ID, ZOZBOT_ID, AUTOPOLLER_ID]: notify_users.add(parent.author.id) soup = BeautifulSoup(body_html, features="html.parser") mentions = soup.find_all("a", href=re.compile("^/@(\w+)")) @@ -546,7 +546,7 @@ def api_comment(v): 'notification': { 'title': f'New reply by @{v.username}', 'body': c.body, - 'deep_link': f'http://{site}{c.permalink}?context=9&read=true#context', + 'deep_link': f'http://{site}/comment/{c.id}?context=9&read=true#context', }, }, }, @@ -696,7 +696,7 @@ def edit_comment(cid, v): - c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + c_jannied = Comment(author_id=AUTOJANNY_ID, parent_submission=c.parent_submission, distinguish_level=6, parent_comment_id=c.id, @@ -730,7 +730,7 @@ def edit_comment(cid, v): - c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + c_jannied = Comment(author_id=AUTOJANNY_ID, parent_submission=c.parent_submission, distinguish_level=6, parent_comment_id=c.id, @@ -865,14 +865,14 @@ def toggle_pin_comment(cid, v): if comment.is_pinned: if v.id != comment.author_id: message = f"@{v.username} has pinned your [comment]({comment.permalink})!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message).first() if not existing: send_notification(comment.author_id, message) g.db.commit() return {"message": "Comment pinned!"} else: if v.id != comment.author_id: message = f"@{v.username} has unpinned your [comment]({comment.permalink})!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message).first() + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message).first() if not existing: send_notification(comment.author_id, message) g.db.commit() return {"message": "Comment unpinned!"} diff --git a/files/routes/front.py b/files/routes/front.py index 2f8e85979..a4107d422 100644 --- a/files/routes/front.py +++ b/files/routes/front.py @@ -37,7 +37,7 @@ def notifications(v): next_exists = (len(comments) > 25) comments = comments[:25] elif posts: - notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all() + notifications = v.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ID).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(101).all() listing = [] @@ -58,7 +58,7 @@ def notifications(v): notifications = v.notifications.join(Notification.comment).filter( Comment.is_banned == False, Comment.deleted_utc == 0, - Comment.author_id != AUTOJANNY_ACCOUNT, + Comment.author_id != AUTOJANNY_ID, ).order_by(Notification.id.desc()).offset(25 * (page - 1)).limit(26).all() next_exists = (len(notifications) > 25) diff --git a/files/routes/oauth.py b/files/routes/oauth.py index bbf8f53ed..58fe568d6 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -49,7 +49,7 @@ def request_api_keys(v): g.db.add(new_app) - send_admin(NOTIFICATIONS_ACCOUNT, f"{v.username} has requested API keys for `{request.values.get('name')}`. You can approve or deny the request [here](/admin/apps).") + send_admin(NOTIFICATIONS_ID, f"{v.username} has requested API keys for `{request.values.get('name')}`. You can approve or deny the request [here](/admin/apps).") g.db.commit() diff --git a/files/routes/posts.py b/files/routes/posts.py index dc22cd8af..c68eef60e 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -139,7 +139,7 @@ def post_id(pid, anything=None, v=None): comments=comments.filter( Comment.parent_submission == post.id, - Comment.author_id != AUTOPOLLER_ACCOUNT, + Comment.author_id != AUTOPOLLER_ID, ).join( votes, votes.c.comment_id == Comment.id, @@ -176,7 +176,7 @@ def post_id(pid, anything=None, v=None): post.replies = [x for x in output if x.is_pinned] + [x for x in output if x.level == 1 and not x.is_pinned] else: - comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ACCOUNT) + comments = g.db.query(Comment).join(User, User.id == Comment.author_id).filter(User.shadowbanned == None, Comment.parent_submission == post.id, Comment.author_id != AUTOPOLLER_ID) if sort == "new": comments = comments.order_by(Comment.created_utc.desc()) @@ -271,7 +271,7 @@ def edit_post(pid, v): body_jannied_html = sanitize(body_md) - c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + c_jannied = Comment(author_id=AUTOJANNY_ID, parent_submission=p.id, level=1, over_18=False, @@ -303,7 +303,7 @@ def edit_post(pid, v): body_jannied_html = sanitize(body_md) - c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + c_jannied = Comment(author_id=AUTOJANNY_ID, parent_submission=p.id, level=1, over_18=False, @@ -338,7 +338,7 @@ def edit_post(pid, v): if ('idio3' in f'{body_html}{title}'.lower() or 'idio ' in f'{body_html}{title}'.lower()) and 30 not in notify_users: notify_users.add(30) for x in notify_users: - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message, Comment.notifiedto == x).first() + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message, Comment.notifiedto == x).first() if not existing: send_notification(x, message) @@ -650,7 +650,7 @@ def submit_post(v): post.ban_reason = "AutoJanny" g.db.add(post) ma=ModAction( - user_id=AUTOJANNY_ACCOUNT, + user_id=AUTOJANNY_ID, target_submission_id=post.id, kind="ban_post", _note="spam" @@ -713,7 +713,7 @@ def submit_post(v): g.db.flush() for option in options: - c = Comment(author_id=AUTOPOLLER_ACCOUNT, + c = Comment(author_id=AUTOPOLLER_ID, parent_submission=new_post.id, level=1, body_html=filter_title(option), @@ -812,7 +812,7 @@ def submit_post(v): body_jannied_html = sanitize(body_md) - c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + c_jannied = Comment(author_id=AUTOJANNY_ID, parent_submission=new_post.id, level=1, over_18=False, @@ -846,7 +846,7 @@ def submit_post(v): - c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, + c_jannied = Comment(author_id=AUTOJANNY_ID, parent_submission=new_post.id, level=1, over_18=False, @@ -884,7 +884,7 @@ def submit_post(v): if new_post.url: if new_post.url.startswith('https://old.reddit.com/r/'): rev = new_post.url.replace('https://old.reddit.com/', '') - rev = "* [reveddit.com](https://reveddit.com/{rev})\n" + rev = f"* [reveddit.com](https://reveddit.com/{rev})\n" else: rev = '' body += f"Snapshots:\n\n{rev}* [archive.org](https://web.archive.org/{new_post.url})\n* [archive.ph](https://archive.ph/?url={quote(new_post.url)}&run=1) (click to archive)\n\n" gevent.spawn(archiveorg, new_post.url) @@ -898,7 +898,7 @@ def submit_post(v): if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n" body += f'**[{title}]({href})**:\n\n' - body += f'* [reveddit.com](https://reveddit.com/{href})\n' + body += f'* [reveddit.com](https://reveddit.com/{href.replace("https://old.reddit.com/", "")})\n' body += f'* [archive.org](https://web.archive.org/{href})\n' body += f'* [archive.ph](https://archive.ph/?url={quote(href)}&run=1) (click to archive)\n\n' gevent.spawn(archiveorg, href) @@ -907,7 +907,7 @@ def submit_post(v): body_html = sanitize(body_md) if len(body_html) < 20000: - c = Comment(author_id=SNAPPY_ACCOUNT, + c = Comment(author_id=SNAPPY_ID, distinguish_level=6, parent_submission=new_post.id, level=1, @@ -919,7 +919,7 @@ def submit_post(v): g.db.add(c) - snappy = g.db.query(User).filter_by(id = SNAPPY_ACCOUNT).first() + snappy = g.db.query(User).filter_by(id = SNAPPY_ID).first() snappy.comment_count += 1 snappy.coins += 1 g.db.add(snappy) diff --git a/files/routes/settings.py b/files/routes/settings.py index fcced4a6c..3adf80591 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -240,7 +240,7 @@ def settings_profile_post(v): for x in notify_users: message = f"@{v.username} has added you to their friends list!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message, Comment.notifiedto == x).first() + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message, Comment.notifiedto == x).first() if not existing: send_notification(x, message) v.friends = friends[:500] @@ -285,7 +285,7 @@ def settings_profile_post(v): for x in notify_users: message = f"@{v.username} has added you to their enemies list!" - existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ACCOUNT, Comment.body == message, Comment.notifiedto == x).first() + existing = g.db.query(Comment.id).filter(Comment.author_id == NOTIFICATIONS_ID, Comment.body == message, Comment.notifiedto == x).first() if not existing: send_notification(x, message) v.enemies = enemies[:500] @@ -825,7 +825,7 @@ def settings_block_user(v): if v.has_block(user): return {"error": f"You have already blocked @{user.username}."}, 409 - if user.id == NOTIFICATIONS_ACCOUNT: + if user.id == NOTIFICATIONS_ID: return {"error": "You can't block this user."}, 409 new_block = UserBlock(user_id=v.id, diff --git a/files/templates/comments.html b/files/templates/comments.html index d2b7ba456..7b3600ec7 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -255,7 +255,7 @@ {% else %} {{c.post.realtitle(v) | safe}} {% endif %} - {% elif c.author_id==NOTIFICATIONS_ACCOUNT or c.author_id==AUTOJANNY_ACCOUNT %} + {% elif c.author_id==NOTIFICATIONS_ID or c.author_id==AUTOJANNY_ID %} {{'SITE_NAME' | app_config}} Notification {% else %} {% if c.sentto == 0 %} @@ -347,7 +347,7 @@ {% endif %} - {% if not c.parent_submission and c.author_id!=NOTIFICATIONS_ACCOUNT and c.author_id!=AUTOJANNY_ACCOUNT and c.author_id!=v.id %} + {% if not c.parent_submission and c.author_id!=NOTIFICATIONS_ID and c.author_id!=AUTOJANNY_ID and c.author_id!=v.id %} Reply

 					
@@ -579,7 +579,7 @@
{% elif replies %}
- More comments + More comments
{% endif %} {% endif %}