diff --git a/docker-compose.yml b/docker-compose.yml index 5bcec7e89..2759a7900 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -20,8 +20,8 @@ services: #- HCAPTCHA_SITEKEY=3435tdfsdudebussylmaoxxt43 - HCAPTCHA_SECRET=3435tdfsdudebussylmaoxxt43 - YOUTUBE_KEY=3435tdfsdudebussylmaoxxt43 + #- PUSHER_ID=3435tdfsdudebussylmaoxxt43 - PUSHER_KEY=3435tdfsdudebussylmaoxxt43 - - PUSHER_ID=3435tdfsdudebussylmaoxxt43 - IMGUR_KEY=3435tdfsdudebussylmaoxxt43 - SPAM_SIMILARITY_THRESHOLD=0.5 - SPAM_URL_SIMILARITY_THRESHOLD=0.1 diff --git a/files/helpers/const.py b/files/helpers/const.py index 91c0a8585..6048a84f1 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -122,7 +122,7 @@ def torture_ap(body, username): 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.", ':#marseywoah:', '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!', "Damn, you're really mad over this, but thanks for the effort you put into typing that all out! Sadly I won't read it all.", "Jesse what the fuck are you talking about??") -AGENDAPOSTER_PHRASE = 'black lives matter' +AGENDAPOSTER_PHRASE = 'trans lives matter' AGENDAPOSTER_MSG = """Hi @{username},\n\nYour {type} has been automatically removed because you forgot to include `{AGENDAPOSTER_PHRASE}`.\n\nDon't worry, we're here to help! We @@ -787,3 +787,4 @@ NOTIFIED_USERS = { } num_banners = len(listdir('files/assets/images/Drama/banners')) + 1 +num_sidebar = len(listdir('files/assets/images/Drama/sidebar')) + 1 \ No newline at end of file diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index 42c926ab4..be6a35949 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -24,4 +24,4 @@ def post_embed(id, v): @app.context_processor def inject_constants(): - return {"num_banners":num_banners, "environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID": AUTOJANNY_ID, "NOTIFICATIONS_ID": NOTIFICATIONS_ID, "PUSHER_ID": PUSHER_ID} \ No newline at end of file + return {"num_banners":num_banners, "num_sidebar":num_sidebar, "environ":environ, "SITE_NAME":SITE_NAME, "AUTOJANNY_ID": AUTOJANNY_ID, "NOTIFICATIONS_ID": NOTIFICATIONS_ID, "PUSHER_ID": PUSHER_ID} \ No newline at end of file diff --git a/files/helpers/sanitize.py b/files/helpers/sanitize.py index b99e83d42..b9683cf08 100644 --- a/files/helpers/sanitize.py +++ b/files/helpers/sanitize.py @@ -245,10 +245,12 @@ def sanitize(sanitized, noimages=False, alert=False, comment=False): htmlsource += '">' sanitized = sanitized.replace(replacing, htmlsource) - for i in re.finditer('>(https://.*?\.(mp4|webm|mov))

', sanitized): - sanitized = sanitized.replace(f'

{i.group(1)}

', f'

') - for i in re.finditer('

(https:.*?\.(mp4|webm|mov))

', sanitized): - sanitized = sanitized.replace(i.group(0), f'

') + + if not noimages: + for i in re.finditer('>(https://.*?\.(mp4|webm|mov))

', sanitized): + sanitized = sanitized.replace(f'

{i.group(1)}

', f'

') + for i in re.finditer('

(https:.*?\.(mp4|webm|mov))

', sanitized): + sanitized = sanitized.replace(i.group(0), f'

') for rd in ["://reddit.com", "://new.reddit.com", "://www.reddit.com", "://redd.it", "://libredd.it"]: sanitized = sanitized.replace(rd, "://old.reddit.com") diff --git a/files/routes/comments.py b/files/routes/comments.py index eb881dd88..0a5f6fc6d 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -16,10 +16,7 @@ if site == 'pcmemes.net': cc = "SPLASH MOUNTAIN" else: cc = "COUNTRY CLUB" IMGUR_KEY = environ.get("IMGUR_KEY").strip() -beams_client = PushNotifications( - instance_id=PUSHER_ID, - secret_key=PUSHER_KEY, -) +if PUSHER_ID: beams_client = PushNotifications(instance_id=PUSHER_ID, secret_key=PUSHER_KEY) @app.get("/comment/") @app.get("/post///") @@ -161,7 +158,7 @@ def api_comment(v): body = request.values.get("body", "").strip()[:10000] if v.marseyawarded: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) + marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body)) if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403 @@ -332,7 +329,7 @@ def api_comment(v): g.db.add(c) - body = AGENDAPOSTER_MSG.format(username=v.username, type='comment') + body = AGENDAPOSTER_MSG.format(username=v.username, type='comment', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE) body_jannied_html = sanitize(body) @@ -465,7 +462,7 @@ def api_comment(v): n = Notification(comment_id=c.id, user_id=x) g.db.add(n) - if parent.author.id != v.id: + if parent.author.id != v.id and PUSHER_ID: if len(c.body) > 500: notifbody = c.body[:500] + '...' else: notifbody = c.body @@ -561,7 +558,7 @@ def edit_comment(cid, v): if body != c.body or request.files.get("file") and request.headers.get("cf-ipcountry") != "T1": if v.marseyawarded: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) + marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body)) if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403 @@ -674,7 +671,7 @@ def edit_comment(cid, v): g.db.add(c) - body = AGENDAPOSTER_MSG.format(username=v.username, type='comment') + body = AGENDAPOSTER_MSG.format(username=v.username, type='comment', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE) body_jannied_html = sanitize(body) diff --git a/files/routes/posts.py b/files/routes/posts.py index 61fb2d8e4..bf444bebb 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -403,10 +403,10 @@ def edit_post(pid, v): if len(body) > 10000: return {"error":"Character limit is 10000!"}, 403 if v.marseyawarded: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", title)) + marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", title)) if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 if body: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) + marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body)) if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403 @@ -483,7 +483,7 @@ def edit_post(pid, v): g.db.add(p) - body = AGENDAPOSTER_MSG.format(username=v.username, type='post') + body = AGENDAPOSTER_MSG.format(username=v.username, type='post', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE) body_jannied_html = sanitize(body) @@ -789,10 +789,10 @@ def submit_post(v): else: render_template("submit.html", v=v, error="500 character limit for titles.", title=title[:500], url=url, body=request.values.get("body", "")), 400 if v.marseyawarded: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", title)) + marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", title)) if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 if body: - marregex = list(re.finditer("^(:!?m\w+:\s*)+$", body)) + marregex = list(re.finditer("^(:[!#]{0,2}m\w+:\s*)+$", body)) if len(marregex) == 0: return {"error":"You can only type marseys!"}, 403 if v.longpost and len(body) < 280 or ' [](' in body or body.startswith('[]('): return {"error":"You have to type more than 280 characters!"}, 403 @@ -1013,7 +1013,7 @@ def submit_post(v): new_post.is_banned = True new_post.ban_reason = "AutoJanny" - body = AGENDAPOSTER_MSG.format(username=v.username, type='post') + body = AGENDAPOSTER_MSG.format(username=v.username, type='post', AGENDAPOSTER_PHRASE=AGENDAPOSTER_PHRASE) body_jannied_html = sanitize(body) diff --git a/files/routes/users.py b/files/routes/users.py index 44f1c3d34..4842d0844 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -14,7 +14,7 @@ from collections import Counter site = environ.get("DOMAIN").strip() -beams_client = PushNotifications(instance_id=PUSHER_ID, secret_key=PUSHER_KEY) +if PUSHER_ID: beams_client = PushNotifications(instance_id=PUSHER_ID, secret_key=PUSHER_KEY) db = db_session() @@ -442,31 +442,32 @@ def message2(v, username): notif = Notification(comment_id=new_comment.id, user_id=user.id) g.db.add(notif) - if len(message) > 500: notifbody = message[:500] + '...' - else: notifbody = message + if PUSHER_ID: + if len(message) > 500: notifbody = message[:500] + '...' + else: notifbody = message - beams_client.publish_to_interests( - interests=[f'{request.host}{user.id}'], - publish_body={ - 'web': { - 'notification': { - 'title': f'New message from @{v.username}', - 'body': notifbody, - 'deep_link': f'https://{site}/notifications?messages=true', - 'icon': f'https://{request.host}/assets/images/{SITE_NAME}/icon.webp', + beams_client.publish_to_interests( + interests=[f'{request.host}{user.id}'], + publish_body={ + 'web': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': notifbody, + 'deep_link': f'https://{site}/notifications?messages=true', + 'icon': f'https://{request.host}/assets/images/{SITE_NAME}/icon.webp', + } + }, + 'fcm': { + 'notification': { + 'title': f'New message from @{v.username}', + 'body': notifbody, + }, + 'data': { + 'url': 'notifications?messages=true', + } } }, - 'fcm': { - 'notification': { - 'title': f'New message from @{v.username}', - 'body': notifbody, - }, - 'data': { - 'url': 'notifications?messages=true', - } - } - }, - ) + ) g.db.commit() @@ -505,7 +506,7 @@ def messagereply(v): g.db.add(new_comment) g.db.flush() - if user_id != v.id: + if PUSHER_ID and user_id != v.id: notif = Notification(comment_id=new_comment.id, user_id=user_id) g.db.add(notif) diff --git a/files/templates/default.html b/files/templates/default.html index 94c33166a..52a6add5d 100644 --- a/files/templates/default.html +++ b/files/templates/default.html @@ -226,9 +226,17 @@ {% if v %} - - - + + {% if SITE_NAME == 'Drama' %} + + + + {% else %} + + + + {% endif %} + {% else %} diff --git a/files/templates/home.html b/files/templates/home.html index 645eb45af..5440dc6fd 100644 --- a/files/templates/home.html +++ b/files/templates/home.html @@ -165,7 +165,7 @@ {% endif %} -{% if v %} +{% if PUSHER_ID and v %}

{{request.host}}{{v.id}}
{{PUSHER_ID}}
diff --git a/files/templates/sidebar_Drama.html b/files/templates/sidebar_Drama.html index d98e187fb..dd8e7b973 100644 --- a/files/templates/sidebar_Drama.html +++ b/files/templates/sidebar_Drama.html @@ -1,6 +1,6 @@