diff --git a/files/__main__.py b/files/__main__.py index 98c8a14194..ca7afd5fb0 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -257,4 +257,4 @@ def after_request(response): response.headers.add("Feature-Policy", "geolocation 'none'; midi 'none'; notifications 'none'; push 'none'; sync-xhr 'none'; microphone 'none'; camera 'none'; magnetometer 'none'; gyroscope 'none'; vibrate 'none'; fullscreen 'none'; payment 'none';") response.headers.add("X-Frame-Options", "deny") - return response \ No newline at end of file + return response diff --git a/files/classes/comment.py b/files/classes/comment.py index 43d261d605..1016991bdf 100644 --- a/files/classes/comment.py +++ b/files/classes/comment.py @@ -4,6 +4,7 @@ from flask import * from sqlalchemy import * from sqlalchemy.orm import relationship, deferred from files.helpers.lazy import lazy +from files.helpers.const import SLURS from files.__main__ import Base from .mix_ins import * from .flags import CommentFlag @@ -246,7 +247,10 @@ class Comment(Base, Age_times, Scores, Stndrd, Fuzzing): def realbody(self, v): body = self.comment_aux.body_html - if not v or v.slurreplacer: body = body.replace(" nigger"," 🏀").replace(" Nigger"," 🏀").replace(" NIGGER"," 🏀").replace(" pedo"," libertarian").replace(" Pedo"," Libertarian ").replace(" PEDO"," LIBERTARIAN ").replace(" tranny"," 🚄").replace(" Tranny"," 🚄").replace(" TRANNY"," 🚄").replace(" fag"," cute twink").replace(" Fag"," Cute twink").replace(" FAG"," CUTE TWINK").replace(" faggot"," cute twink").replace(" Faggot"," Cute twink").replace(" FAGGOT"," CUTE TWINK").replace(" steve akins"," penny verity oaken").replace(" Steve Akins"," Penny Verity Oaken").replace(" STEVE AKINS"," PENNY VERITY OAKEN").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" kill yourself"," keep yourself safe").replace(" KILL YOURSELF"," KEEP YOURSELF SAFE").replace(" trannie"," 🚄").replace(" Trannie"," 🚄").replace(" TRANNIE"," 🚄").replace(" troon"," 🚄").replace(" Troon"," 🚄").replace(" TROON"," 🚄") + + if not v or v.slurreplacer: + for s,r in SLURS.items(): body = body.replace(s, r) + if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com") if v and v.controversial: diff --git a/files/classes/submission.py b/files/classes/submission.py index 21da28405c..1eda5a81a4 100644 --- a/files/classes/submission.py +++ b/files/classes/submission.py @@ -4,6 +4,7 @@ from sqlalchemy.orm import relationship, deferred import re, random from urllib.parse import urlparse from files.helpers.lazy import lazy +from files.helpers.const import SLURS from files.__main__ import Base from .mix_ins import * from .flags import * @@ -342,7 +343,11 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): def realbody(self, v): body = self.submission_aux.body_html - if not v or v.slurreplacer: body = body.replace(" nigger"," 🏀").replace(" Nigger"," 🏀").replace(" NIGGER"," 🏀").replace(" pedo"," libertarian").replace(" Pedo"," Libertarian ").replace(" PEDO"," LIBERTARIAN ").replace(" tranny"," 🚄").replace(" Tranny"," 🚄").replace(" TRANNY"," 🚄").replace(" fag"," cute twink").replace(" Fag"," Cute twink").replace(" FAG"," CUTE TWINK").replace(" faggot"," cute twink").replace(" Faggot"," Cute twink").replace(" FAGGOT"," CUTE TWINK").replace(" steve akins"," penny verity oaken").replace(" Steve Akins"," Penny Verity Oaken").replace(" STEVE AKINS"," PENNY VERITY OAKEN").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" kill yourself"," keep yourself safe").replace(" KILL YOURSELF"," KEEP YOURSELF SAFE").replace(" trannie"," 🚄").replace(" Trannie"," 🚄").replace(" TRANNIE"," 🚄").replace(" troon"," 🚄").replace(" Troon"," 🚄").replace(" TROON"," 🚄") + + if not v or v.slurreplacer: + for s,r in SLURS.items(): + body = body.replace(s, r) + if v and not v.oldreddit: body = body.replace("old.reddit.com", "reddit.com") return body @@ -358,7 +363,10 @@ class Submission(Base, Stndrd, Age_times, Scores, Fuzzing): def realtitle(self, v): if self.title_html: title = self.title_html else: title = self.title - if not v or v.slurreplacer: title = title.replace(" nigger"," 🏀").replace(" Nigger"," 🏀").replace(" NIGGER"," 🏀").replace(" pedo"," libertarian").replace(" Pedo"," Libertarian ").replace(" PEDO"," LIBERTARIAN ").replace(" tranny"," 🚄").replace(" Tranny"," 🚄").replace(" TRANNY"," 🚄").replace(" fag"," cute twink").replace(" Fag"," Cute twink").replace(" FAG"," CUTE TWINK").replace(" faggot"," cute twink").replace(" Faggot"," Cute twink").replace(" FAGGOT"," CUTE TWINK").replace(" steve akins"," penny verity oaken").replace(" Steve Akins"," Penny Verity Oaken").replace(" STEVE AKINS"," PENNY VERITY OAKEN").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" RETARD"," RSLUR").replace(" rapist"," male feminist").replace(" Rapist"," Male feminist").replace(" RAPIST"," MALE FEMINIST").replace(" kill yourself"," keep yourself safe").replace(" KILL YOURSELF"," KEEP YOURSELF SAFE").replace(" trannie"," 🚄").replace(" Trannie"," 🚄").replace(" TRANNIE"," 🚄").replace(" troon"," 🚄").replace(" Troon"," 🚄").replace(" TROON"," 🚄") + + if not v or v.slurreplacer: + for s,r in SLURS.items(): title = title.replace(s, r) + return title @property @@ -412,4 +420,4 @@ class SaveRelationship(Base, Stndrd): id=Column(Integer, primary_key=true) user_id=Column(Integer, ForeignKey("users.id")) submission_id=Column(Integer, ForeignKey("submissions.id")) - type=Column(Integer) \ No newline at end of file + type=Column(Integer) diff --git a/files/classes/user.py b/files/classes/user.py index dcabb0e907..576c186f8a 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -4,6 +4,7 @@ import pyotp from files.helpers.discord import delete_role from files.helpers.images import * +from files.helpers.const import * from .alts import Alt from .submission import SaveRelationship from .comment import Notification @@ -345,11 +346,11 @@ class User(Base, Stndrd, Age_times): @lazy def post_notifications_count(self): return self.notifications.filter(Notification.read == False).join(Notification.comment).filter( - Comment.author_id == 2360).count() + Comment.author_id == AUTOJANNY_ACCOUNT).count() def notification_subscriptions(self, page=1, all_=False): - notifications = self.notifications.join(Notification.comment).filter(Comment.author_id == 2360) + notifications = self.notifications.join(Notification.comment).filter(Comment.author_id == AUTOJANNY_ACCOUNT) notifications = notifications.options( contains_eager(Notification.comment) @@ -370,7 +371,7 @@ class User(Base, Stndrd, Age_times): notifications = self.notifications.join(Notification.comment).filter( Comment.is_banned == False, Comment.deleted_utc == 0, - Comment.author_id != 2360, + Comment.author_id != AUTOJANNY_ACCOUNT, ) if not all_: @@ -536,7 +537,7 @@ class User(Base, Stndrd, Age_times): self.profileurl = None delete_role(self, "linked") - self.is_banned = admin.id if admin else 2360 + self.is_banned = admin.id if admin else AUTOJANNY_ACCOUNT if reason: self.ban_reason = reason g.db.add(self) @@ -703,4 +704,4 @@ class ViewerRelationship(Base): return f"{months}mo ago" else: years = int(months / 12) - return f"{years}yr ago" \ No newline at end of file + return f"{years}yr ago" diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 8bcc7afc42..5b5d3389d3 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -4,6 +4,7 @@ from files.classes import * from flask import g from .markdown import * from .sanitize import * +from .const import * def send_notification(vid, user, text): @@ -63,7 +64,7 @@ def send_follow_notif(vid, user, text): with CustomRenderer() as renderer: text_html = renderer.render(mistletoe.Document(text)) text_html = sanitize(text_html) - new_comment = Comment(author_id=1046, + new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT, parent_submission=None, distinguish_level=6, ) @@ -89,7 +90,7 @@ def send_unfollow_notif(vid, user, text): text_html = renderer.render(mistletoe.Document(text)) text_html = sanitize(text_html) - new_comment = Comment(author_id=1046, + new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT, parent_submission=None, distinguish_level=6, ) @@ -115,7 +116,7 @@ def send_block_notif(vid, user, text): text_html = renderer.render(mistletoe.Document(text)) text_html = sanitize(text_html) - new_comment = Comment(author_id=1046, + new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT, parent_submission=None, distinguish_level=6, ) @@ -141,7 +142,7 @@ def send_unblock_notif(vid, user, text): text_html = renderer.render(mistletoe.Document(text)) text_html = sanitize(text_html) - new_comment = Comment(author_id=1046, + new_comment = Comment(author_id=NOTIFICATIONS_ACCOUNT, parent_submission=None, distinguish_level=6, ) diff --git a/files/helpers/const.py b/files/helpers/const.py new file mode 100644 index 0000000000..dcb84156d8 --- /dev/null +++ b/files/helpers/const.py @@ -0,0 +1,50 @@ +from os import environ + +SLURS = { + " fag":" cute twink", + " Fag":" Cute twink", + " FAG":" CUTE TWINK", + " faggot":" cute twink", + " Faggot":" Cute twink", + " FAGGOT":" CUTE TWINK", + " kill yourself":" keep yourself safe", + " KILL YOURSELF":" KEEP YOURSELF SAFE", + " nigger":" 🏀", + " Nigger":" 🏀", + " NIGGER":" 🏀", + " pedo":" libertarian", + " Pedo":" Libertarian ", + " PEDO":" LIBERTARIAN ", + " rapist":" male feminist", + " Rapist":" Male feminist", + " RAPIST":" MALE FEMINIST", + " RETARD":" RSLUR", + " steve akins":" penny verity oaken", + " Steve Akins":" Penny Verity Oaken", + " STEVE AKINS":" PENNY VERITY OAKEN", + " trannie":" 🚄", + " Trannie":" 🚄", + " TRANNIE":" 🚄", + " tranny":" 🚄", + " Tranny":" 🚄", + " TRANNY":" 🚄", + " troon":" 🚄", + " Troon":" 🚄", + " TROON":" 🚄", +} + +LONGPOST_REPLIES = ['Wow, you must be a JP fan.', 'This is one of the worst posts I have EVER seen. Delete it.', "No, don't reply like this, please do another wall of unhinged rant please.", '# 😴😴😴', "Ma'am we've been over this before. You need to stop.", "I've known more coherent downies.", "Your pulitzer's in the mail", "That's great and all, but I asked for my burger without cheese.", 'That degree finally paying off', "That's nice sweaty. Why don't you have a seat in the time out corner with Pizzashill until you calm down, then you can have your Capri Sun.", "All them words won't bring your pa back.", "You had a chance to not be completely worthless, but it looks like you threw it away. At least you're consistent.", 'Some people are able to display their intelligence by going on at length on a subject and never actually saying anything. This ability is most common in trades such as politics, public relations, and law. You have impressed me by being able to best them all, while still coming off as an absolute idiot.', "You can type 10,000 characters and you decided that these were the one's that you wanted.", 'Have you owned the libs yet?', "I don't know what you said, because I've seen another human naked.", 'Impressive. Normally people with such severe developmental disabilities struggle to write much more than a sentence or two. He really has exceded our expectations for the writing portion. Sadly the coherency of his writing, along with his abilities in the social skills and reading portions, are far behind his peers with similar disabilities.', "This is a really long way of saying you don't fuck.", "Sorry ma'am, looks like his delusions have gotten worse. We'll have to admit him,", '![](https://i.kym-cdn.com/photos/images/newsfeed/001/038/094/0a1.jpg)', 'If only you could put that energy into your relationships', 'Posts like this is why I do Heroine.', 'still unemployed then?', 'K', 'look im gunna have 2 ask u 2 keep ur giant dumps in the toilet not in my replys 😷😷😷', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.", "Good job bobby, here's a star", "That was a mistake. You're about to find out the hard way why.", 'You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit on rdrama.net was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures."] + +AGENDAPOSTER_MSG = """Hi {username},\n\nYour comment has been automatically removed because you forgot + to include `trans lives matter`.\n\nDon't worry, we're here to help! We + won't let you post or comment anything that doesn't express your love and acceptance towards + the trans community. Feel free to resubmit your comment with `trans lives matter` + included. \n\n*This is an automated message; if you need help, + you can message us [here](/contact).*""" + +NOTIFICATIONS_ACCOUNT = 1046 +AUTOJANNY_ACCOUNT = 2360 +LONGPOSTBOT_ACCOUNT = 1832 + +PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6' +PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index f36a2d3d52..16586fa77c 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -1,5 +1,6 @@ from files.__main__ import app from .get import * +from files.helpers import const @app.template_filter("full_link") @@ -19,4 +20,10 @@ def post_embed(id, v): p = get_post(id, graceful=True) - return render_template("submission_listing.html", listing=[p], v=v) \ No newline at end of file + return render_template("submission_listing.html", listing=[p], v=v) + +@app.context_processor +def inject_constants(): + constants = [c for c in dir(const) if not c.startswith("_")] + return {c:getattr(const, c) for c in constants} + diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index 95855a03f8..eaccee9ea5 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -4,6 +4,7 @@ from werkzeug.wrappers.response import Response as RespObj from .get import * from .alerts import send_notification from files.__main__ import app +from files.helpers.const import * def get_logged_in_user(): @@ -48,7 +49,7 @@ def check_ban_evade(v): if random.randint(0,30) < v.ban_evade: v.ban(reason="ban evasion") - send_notification(1046, v, "Your account has been permanently suspended for the following reason:\n\n> ban evasion") + send_notification(NOTIFICATIONS_ACCOUNT, v, "Your account has been permanently suspended for the following reason:\n\n> ban evasion") for post in g.db.query(Submission).filter_by(author_id=v.id).all(): if post.is_banned: @@ -60,7 +61,7 @@ def check_ban_evade(v): ma=ModAction( kind="ban_post", - user_id=2360, + user_id=AUTOJANNY_ACCOUNT, target_submission_id=post.id, note="ban evasion" ) @@ -78,7 +79,7 @@ def check_ban_evade(v): ma=ModAction( kind="ban_comment", - user_id=2360, + user_id=AUTOJANNY_ACCOUNT, target_comment_id=comment.id, note="ban evasion" ) @@ -251,4 +252,4 @@ def api(*scopes, no_ban=False): wrapper.__name__ = f.__name__ return wrapper - return wrapper_maker \ No newline at end of file + return wrapper_maker diff --git a/files/routes/admin.py b/files/routes/admin.py index 7cccd265c9..6623cbce05 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -12,6 +12,7 @@ from files.helpers.markdown import * from files.helpers.security import * from files.helpers.get import * from files.helpers.images import * +from files.helpers.const import * from files.classes import * from flask import * import matplotlib.pyplot as plt @@ -177,7 +178,7 @@ def badge_grant_post(v): \n\n{new_badge.name} """ - send_notification(1046, user, text) + send_notification(NOTIFICATIONS_ACCOUNT, user, text) if badge_id in [21,22,23,24,28]: user.patron = int(str(badge_id)[-1]) @@ -624,7 +625,7 @@ def ban_user(user_id, v): if x.admin_level > 0: break x.ban(admin=v, reason=reason) - send_notification(1046, user, text) + send_notification(NOTIFICATIONS_ACCOUNT, user, text) if days == 0: duration = "permanent" elif days == 1: duration = "1 day" @@ -669,7 +670,7 @@ def unban_user(user_id, v): if x.admin_level == 0: x.unban() - send_notification(1046, user, + send_notification(NOTIFICATIONS_ACCOUNT, user, "Your account has been reinstated. Please carefully review and abide by the [rules](/post/2510) to ensure that you don't get suspended again.") ma=ModAction( @@ -1085,4 +1086,4 @@ def multiple_plots(**kwargs): plt.savefig("image.png") plt.clf() - return upload_file(png=True) \ No newline at end of file + return upload_file(png=True) diff --git a/files/routes/awards.py b/files/routes/awards.py index c347eb24ed..251beaec9a 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -2,6 +2,7 @@ from files.__main__ import app from files.helpers.wrappers import * from files.helpers.alerts import * from files.helpers.get import * +from files.helpers.const import * from files.classes.award import * from flask import g, request @@ -15,12 +16,12 @@ def banaward_trigger(post=None, comment=None): if not author.is_suspended: author.ban(reason="1-day ban award used", days=1) - send_notification(1046, author, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.") + send_notification(NOTIFICATIONS_ACCOUNT, author, f"Your account has been suspended for a day for {link}. It sucked and you should feel bad.") elif author.unban_utc > 0: author.unban_utc += 24*60*60 g.db.add(author) - send_notification(1046, author, f"Your account has been suspended for yet another day for {link}. Seriously man?") + send_notification(NOTIFICATIONS_ACCOUNT, author, f"Your account has been suspended for yet another day for {link}. Seriously man?") ACTIONS = { @@ -100,7 +101,7 @@ def award_post(pid, v): if note: msg += f"\n\n> {note}" - send_notification(1046, post.author, msg) + send_notification(NOTIFICATIONS_ACCOUNT, post.author, msg) if kind in ACTIONS: ACTIONS[kind](post=post) @@ -161,7 +162,7 @@ def award_comment(cid, v): if note: msg += f"\n\n> {note}" - send_notification(1046, c.author, msg) + send_notification(NOTIFICATIONS_ACCOUNT, c.author, msg) if kind in ACTIONS: ACTIONS[kind](comment=c) @@ -217,6 +218,6 @@ def admin_userawards_post(v): for key, value in notify_awards.items(): text += f" - **{value}** {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}\n" - send_notification(1046, u, text) + send_notification(NOTIFICATIONS_ACCOUNT, u, text) return render_template("admin/user_award.html", awards=list(AWARDS.values()), v=v) diff --git a/files/routes/comments.py b/files/routes/comments.py index 6a58fd6efe..14428fca82 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -6,6 +6,7 @@ from files.helpers.filters import * from files.helpers.alerts import * from files.helpers.images import * from files.helpers.session import * +from files.helpers.const import * from files.classes import * from files.routes.front import comment_idlist from pusher_push_notifications import PushNotifications @@ -15,12 +16,8 @@ from files.__main__ import app, limiter site = environ.get("DOMAIN").strip() -choices = ['Wow, you must be a JP fan.', 'This is one of the worst posts I have EVER seen. Delete it.', "No, don't reply like this, please do another wall of unhinged rant please.", '# 😴😴😴', "Ma'am we've been over this before. You need to stop.", "I've known more coherent downies.", "Your pulitzer's in the mail", "That's great and all, but I asked for my burger without cheese.", 'That degree finally paying off', "That's nice sweaty. Why don't you have a seat in the time out corner with Pizzashill until you calm down, then you can have your Capri Sun.", "All them words won't bring your pa back.", "You had a chance to not be completely worthless, but it looks like you threw it away. At least you're consistent.", 'Some people are able to display their intelligence by going on at length on a subject and never actually saying anything. This ability is most common in trades such as politics, public relations, and law. You have impressed me by being able to best them all, while still coming off as an absolute idiot.', "You can type 10,000 characters and you decided that these were the one's that you wanted.", 'Have you owned the libs yet?', "I don't know what you said, because I've seen another human naked.", 'Impressive. Normally people with such severe developmental disabilities struggle to write much more than a sentence or two. He really has exceded our expectations for the writing portion. Sadly the coherency of his writing, along with his abilities in the social skills and reading portions, are far behind his peers with similar disabilities.', "This is a really long way of saying you don't fuck.", "Sorry ma'am, looks like his delusions have gotten worse. We'll have to admit him,", '![](https://i.kym-cdn.com/photos/images/newsfeed/001/038/094/0a1.jpg)', 'If only you could put that energy into your relationships', 'Posts like this is why I do Heroine.', 'still unemployed then?', 'K', 'look im gunna have 2 ask u 2 keep ur giant dumps in the toilet not in my replys 😷😷😷', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures.", "Good job bobby, here's a star", "That was a mistake. You're about to find out the hard way why.", 'You sat down and wrote all this shit. You could have done so many other things with your life. What happened to your life that made you decide writing novels of bullshit on rdrama.net was the best option?', "I don't have enough spoons to read this shit", "All those words won't bring daddy back.", 'OUT!', "Mommy is soooo proud of you, sweaty. Let's put this sperg out up on the fridge with all your other failures."] - -PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() - beams_client = PushNotifications( - instance_id='02ddcc80-b8db-42be-9022-44c546b4dce6', + instance_id=PUSHER_INSTANCE_ID, secret_key=PUSHER_KEY, ) @@ -219,7 +216,7 @@ def api_comment(v): if len(similar_comments) > threshold: text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" - send_notification(1046, v, text) + send_notification(NOTIFICATIONS_ACCOUNT, v, text) v.ban(reason="Spamming.", days=1) @@ -233,7 +230,7 @@ def api_comment(v): comment.ban_reason = "Automatic spam removal. This happened because the post's creator submitted too much similar content too quickly." g.db.add(comment) ma=ModAction( - user_id=2360, + user_id=AUTOJANNY_ACCOUNT, target_comment_id=comment.id, kind="ban_comment", note="spam" @@ -302,7 +299,7 @@ def api_comment(v): g.db.add(c) - c_jannied = Comment(author_id=2360, + c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, parent_submission=parent_submission, distinguish_level=6, parent_comment_id=c.id, @@ -313,12 +310,7 @@ def api_comment(v): g.db.add(c_jannied) g.db.flush() - body = f"""Hi @{v.username},\n\nYour comment has been automatically removed because you forgot - to include `trans lives matter`.\n\nDon't worry, we're here to help! We - won't let you post or comment anything that doesn't express your love and acceptance towards - the trans community. Feel free to resubmit your comment with `trans lives matter` - included. \n\n*This is an automated message; if you need help, - you can message us [here](/contact).*""" + body = AGENDAPOSTER_MSG.format(username=v.username) #body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") with CustomRenderer(post_id=parent_id) as renderer: @@ -336,7 +328,7 @@ def api_comment(v): g.db.add(n) if "rdrama" in request.host and len(body) >= 1000 and v.username != "Snappy" and "" not in body_html: - c2 = Comment(author_id=1832, + c2 = Comment(author_id=LONGPOSTBOT_ACCOUNT, parent_submission=parent_submission, parent_comment_id=c.id, level=level+1, @@ -346,7 +338,7 @@ def api_comment(v): g.db.add(c2) g.db.flush() - body = random.choice(choices) + body = random.choice(LONGPOST_REPLIES) body = body.replace("\n", "\n\n").replace("\n\n\n\n\n\n", "\n\n").replace("\n\n\n\n", "\n\n").replace("\n\n\n", "\n\n") with CustomRenderer(post_id=parent_id) as renderer: body_md = renderer.render(mistletoe.Document(body)) body_html2 = sanitize(body_md) @@ -609,7 +601,7 @@ def edit_comment(cid, v): if len(similar_comments) > threshold: text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" - send_notification(1046, v, text) + send_notification(NOTIFICATIONS_ACCOUNT, v, text) v.ban(reason="Spamming.", days=1) @@ -644,7 +636,7 @@ def edit_comment(cid, v): g.db.add(c) - c_jannied = Comment(author_id=2360, + c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, parent_submission=c.parent_submission, distinguish_level=6, parent_comment_id=c.id, @@ -655,12 +647,7 @@ def edit_comment(cid, v): g.db.add(c_jannied) g.db.flush() - body = f"""Hi @{v.username},\n\nYour comment has been automatically removed because you forgot - to include `trans lives matter`.\n\nDon't worry, we're here to help! We - won't let you post or comment anything that doesn't express your love and acceptance towards - the trans community. Feel free to resubmit your comment with `trans lives matter` - included. \n\n*This is an automated message; if you need help, - you can message us [here](/contact).*""" + body = AGENDAPOSTER_MSG.format(username=v.username) with CustomRenderer(post_id=c.parent_submission) as renderer: body_md = renderer.render(mistletoe.Document(body)) @@ -816,4 +803,4 @@ def unsave_comment(cid, v): if save: g.db.delete(save) - return "", 204 \ No newline at end of file + return "", 204 diff --git a/files/routes/login.py b/files/routes/login.py index e9d5e8cff9..187d8b3230 100644 --- a/files/routes/login.py +++ b/files/routes/login.py @@ -1,6 +1,7 @@ from urllib.parse import urlencode from files.mail import * from files.__main__ import app, limiter +from files.helpers.const import * valid_username_regex = re.compile("^[a-zA-Z0-9_\-]{3,25}$") valid_password_regex = re.compile("^.{8,100}$") @@ -315,8 +316,9 @@ def sign_up_post(v): ref_user.refresh_selfset_badges() g.db.add(ref_user) - users = g.db.query(User).count() - if users == 0: admin_level=6 + id_1 = g.db.query(User).filter_by(id=1).count() + users_count = g.db.query(User).count() #paranoid + if id_1 == 0 and users_count < 6: admin_level=6 else: admin_level=0 # make new user @@ -355,7 +357,7 @@ def sign_up_post(v): if email: send_verification_email(new_user) # send welcome message - if "rdrama" in request.host: send_notification(1046, new_user, "Dude bussy lmao") + if "rdrama" in request.host: send_notification(NOTIFICATIONS_ACCOUNT, new_user, "Dude bussy lmao") session["user_id"] = new_user.id session["session_id"] = token_hex(16) diff --git a/files/routes/oauth.py b/files/routes/oauth.py index c122f74747..f9b3cabd01 100644 --- a/files/routes/oauth.py +++ b/files/routes/oauth.py @@ -1,6 +1,7 @@ from files.helpers.wrappers import * from files.helpers.alerts import * from files.helpers.get import * +from files.helpers.const import * from files.classes import * from flask import * from files.__main__ import app @@ -47,7 +48,7 @@ def request_api_keys(v): g.db.add(new_app) - send_admin(1046, f"@{v.username} has requested API keys for `{request.form.get('name')}`. You can approve or deny the request [here](/admin/apps).") + send_admin(NOTIFICATIONS_ACCOUNT, f"@{v.username} has requested API keys for `{request.form.get('name')}`. You can approve or deny the request [here](/admin/apps).") return redirect('/settings/apps') @@ -105,7 +106,7 @@ def admin_app_approve(v, aid): g.db.add(new_auth) - send_notification(1046, user, f"Your application `{app.app_name}` has been approved. Here's your access token: `{access_token}`\nPlease check the guide [here](/api) if you don't know what to do next.") + send_notification(NOTIFICATIONS_ACCOUNT, user, f"Your application `{app.app_name}` has been approved. Here's your access token: `{access_token}`\nPlease check the guide [here](/api) if you don't know what to do next.") return {"message": f"{app.app_name} approved"} @@ -120,7 +121,7 @@ def admin_app_revoke(v, aid): for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth) g.db.flush() - send_notification(1046, app.author, f"Your application `{app.app_name}` has been revoked.") + send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been revoked.") g.db.delete(app) @@ -137,7 +138,7 @@ def admin_app_reject(v, aid): for auth in g.db.query(ClientAuth).filter_by(oauth_client=app.id).all(): g.db.delete(auth) g.db.flush() - send_notification(1046, app.author, f"Your application `{app.app_name}` has been rejected.") + send_notification(NOTIFICATIONS_ACCOUNT, app.author, f"Your application `{app.app_name}` has been rejected.") g.db.delete(app) @@ -221,4 +222,4 @@ def reroll_oauth_tokens(aid, v): a.client_id = secrets.token_urlsafe(64)[:64] g.db.add(a) - return {"message": "Client ID Rerolled", "id": a.client_id} \ No newline at end of file + return {"message": "Client ID Rerolled", "id": a.client_id} diff --git a/files/routes/posts.py b/files/routes/posts.py index 44ba6a6607..811c407fd4 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -11,6 +11,7 @@ from files.helpers.session import * from files.helpers.thumbs import * from files.helpers.alerts import send_notification from files.helpers.discord import send_message +from files.helpers.const import * from files.classes import * from flask import * from io import BytesIO @@ -277,7 +278,7 @@ def edit_post(pid, v): if badlink: if badlink.autoban: text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" - send_notification(1046, v, text) + send_notification(NOTIFICATIONS_ACCOUNT, v, text) v.ban(days=1, reason="spam") return redirect('/notifications') @@ -301,7 +302,7 @@ def edit_post(pid, v): g.db.add(p) - c_jannied = Comment(author_id=2360, + c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, parent_submission=p.id, level=1, over_18=False, @@ -314,12 +315,7 @@ def edit_post(pid, v): g.db.add(c_jannied) g.db.flush() - body = f"""Hi @{v.username},\n\nYour post has been automatically removed because you forgot - to include `trans lives matter`.\n\nDon't worry, we're here to help! We - won't let you post or comment anything that doesn't express your love and acceptance towards - the trans community. Feel free to resubmit your post with `trans lives matter` - included. \n\n*This is an automated message; if you need help, - you can message us [here](/contact).*""" + body = AGENDAPOSTER_MSG.format(username=v.username) with CustomRenderer(post_id=p.id) as renderer: body_md = renderer.render(mistletoe.Document(body)) @@ -343,7 +339,7 @@ def edit_post(pid, v): user = g.db.query(User).filter_by(username=username).first() if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user) - for x in notify_users: send_notification(1046, x, f"@{v.username} has mentioned you: https://{site}{p.permalink}") + for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{p.permalink}") return redirect(p.permalink) @@ -670,7 +666,7 @@ def submit_post(v): if max(len(similar_urls), len(similar_posts)) >= threshold: text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" - send_notification(1046, v, text) + send_notification(NOTIFICATIONS_ACCOUNT, v, text) v.ban(reason="Spamming.", days=1) @@ -685,7 +681,7 @@ def submit_post(v): post.ban_reason = "Automatic spam removal. This happened because the post's creator submitted too much similar content too quickly." g.db.add(post) ma=ModAction( - user_id=2360, + user_id=AUTOJANNY_ACCOUNT, target_submission_id=post.id, kind="ban_post", note="spam" @@ -749,7 +745,7 @@ def submit_post(v): if badlink: if badlink.autoban: text = "Your account has been suspended for 1 day for the following reason:\n\n> Too much spam!" - send_notification(1046, v, text) + send_notification(NOTIFICATIONS_ACCOUNT, v, text) v.ban(days=1, reason="spam") return redirect('/notifications') @@ -830,12 +826,12 @@ def submit_post(v): user = g.db.query(User).filter_by(username=username).first() if user and not v.any_block_exists(user) and user.id != v.id: notify_users.add(user) - for x in notify_users: send_notification(1046, x, f"@{v.username} has mentioned you: https://{site}{new_post.permalink}") + for x in notify_users: send_notification(NOTIFICATIONS_ACCOUNT, x, f"@{v.username} has mentioned you: https://{site}{new_post.permalink}") if not new_post.private: for follow in v.followers: user = get_account(follow.user_id) - send_notification(2360, user, f"@{v.username} has made a new post: [{title}](https://{site}{new_post.permalink})") + send_notification(AUTOJANNY_ACCOUNT, user, f"@{v.username} has made a new post: [{title}](https://{site}{new_post.permalink})") g.db.add(new_post) g.db.flush() @@ -847,7 +843,7 @@ def submit_post(v): g.db.add(new_post) - c_jannied = Comment(author_id=2360, + c_jannied = Comment(author_id=AUTOJANNY_ACCOUNT, parent_submission=new_post.id, level=1, over_18=False, @@ -860,12 +856,7 @@ def submit_post(v): g.db.add(c_jannied) g.db.flush() - body = f"""Hi @{v.username},\n\nYour post has been automatically removed because you forgot - to include `trans lives matter`.\n\nDon't worry, we're here to help! We - won't let you post or comment anything that doesn't express your love and acceptance towards - the trans community. Feel free to resubmit your post with `trans lives matter` - included. \n\n*This is an automated message; if you need help, - you can message us [here](/contact).*""" + body = AGENDAPOSTER_MSG.format(username=v.username) with CustomRenderer(post_id=new_post.id) as renderer: body_md = renderer.render(mistletoe.Document(body)) diff --git a/files/routes/settings.py b/files/routes/settings.py index 8e9a4b9699..28477a011a 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -4,6 +4,7 @@ from files.helpers.sanitize import * from files.helpers.filters import filter_comment_html from files.helpers.markdown import * from files.helpers.discord import remove_user, set_nick +from files.helpers.const import * from files.mail import * from files.__main__ import app, cache import youtube_dl @@ -466,7 +467,7 @@ def settings_block_user(v): if v.has_block(user): return {"error": f"You have already blocked @{user.username}."}, 409 - if user.id == 1046: + if user.id == NOTIFICATIONS_ACCOUNT: return {"error": "You can't block @files."}, 409 new_block = UserBlock(user_id=v.id, diff --git a/files/routes/users.py b/files/routes/users.py index 4c853d9f35..d70b9baefc 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -8,6 +8,7 @@ from files.classes.user import ViewerRelationship from files.helpers.alerts import * from files.helpers.sanitize import * from files.helpers.markdown import * +from files.helpers.const import * from files.mail import * from flask import * from files.__main__ import app, limiter @@ -15,10 +16,8 @@ from pusher_push_notifications import PushNotifications site = environ.get("DOMAIN").strip() -PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() - beams_client = PushNotifications( - instance_id='02ddcc80-b8db-42be-9022-44c546b4dce6', + instance_id=PUSHER_INSTANCE_ID, secret_key=PUSHER_KEY, ) @@ -29,7 +28,7 @@ def suicide(v, username): if v.admin_level == 0 and t - v.suicide_utc < 86400: return "", 204 user = get_user(username) suicide = f"Hi there,\n\nA [concerned user]({v.url}) reached out to us about you.\n\nWhen you're in the middle of something painful, it may feel like you don't have a lot of options. But whatever you're going through, you deserve help and there are people who are here for you.\n\nThere are resources available in your area that are free, confidential, and available 24/7:\n\n- Call, Text, or Chat with Canada's [Crisis Services Canada](https://www.crisisservicescanada.ca/en/)\n- Call, Email, or Visit the UK's [Samaritans](https://www.samaritans.org/)\n- Text CHAT to America's [Crisis Text Line](https://www.crisistextline.org/) at 741741.\nIf you don't see a resource in your area above, the moderators at r/SuicideWatch keep a comprehensive list of resources and hotlines for people organized by location. Find Someone Now\n\nIf you think you may be depressed or struggling in another way, don't ignore it or brush it aside. Take yourself and your feelings seriously, and reach out to someone.\n\nIt may not feel like it, but you have options. There are people available to listen to you, and ways to move forward.\n\nYour fellow users care about you and there are people who want to help." - send_notification(1046, user, suicide) + send_notification(NOTIFICATIONS_ACCOUNT, user, suicide) v.suicide_utc = t g.db.add(v) return "", 204 @@ -327,7 +326,7 @@ def u_username(username, v=None): # g.db.add(v) # u.coins += 500 # g.db.add(u) - # send_notification(1046, u, f"@{v.username} has paid rent!") + # send_notification(NOTIFICATIONS_ACCOUNT, u, f"@{v.username} has paid rent!") # paidrent = True # if not paidrent: @@ -433,7 +432,7 @@ def u_username_comments(username, v=None): # g.db.add(v) # u.coins += 500 # g.db.add(u) - # send_notification(1046, u, f"@{v.username} has paid rent!") + # send_notification(NOTIFICATIONS_ACCOUNT, u, f"@{v.username} has paid rent!") # paidrent = True # if not paidrent: diff --git a/files/templates/comments.html b/files/templates/comments.html index ea1a340442..7ed104bd89 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -92,7 +92,7 @@ {% else %} {{c.post.realtitle(v) | safe}} {% endif %} - {% elif c.author_id==1046 or c.author_id==2360 %} + {% elif c.author_id==NOTIFICATIONS_ACCOUNT or c.author_id==AUTOJANNY_ACCOUNT %} {{'SITE_NAME' | app_config}} Notification {% else %} Private Message @@ -161,7 +161,7 @@