diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 01110ef1c..54b63d0f7 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -104,8 +104,18 @@ def NOTIFY_USERS(text, v): soup = BeautifulSoup(text, features="html.parser") for mention in soup.find_all("a", href=re.compile("^\/id\/([0-9]+)")): id = int(mention["href"].split("/id/")[1]) - if id != v.id: - user = g.db.query(User).filter_by(id=id).one_or_none() - if user and not v.any_block_exists(user): notify_users.add(user.id) + if id != v.id: notify_users.add(id) + + return notify_users + +def NOTIFY_USERS2(text, v): + notify_users = set() + for word, id in NOTIFIED_USERS.items(): + if id == 0: continue + if word in text.lower() and id not in notify_users and v.id != id: notify_users.add(id) + + for i in re.finditer("(^|\s|\n)@((\w|-){1,25})", text): + user = get_user(i.group(2), graceful=True) + if user and not v.any_block_exists(user): notify_users.add(user.id) return notify_users \ No newline at end of file diff --git a/files/helpers/markdown.py b/files/helpers/markdown.py index 7b5118c9b..eb0aa0be5 100644 --- a/files/helpers/markdown.py +++ b/files/helpers/markdown.py @@ -39,6 +39,7 @@ class CustomRenderer(HTMLRenderer): user = get_user(target, graceful=True) + if g.v.admin_level == 0 and g.v.any_block_exists(user): return f"{space}@{target}" if not user: return f"{space}@{target}" @@ -67,6 +68,8 @@ class Renderer(HTMLRenderer): user = get_user(target, graceful=True) + if g.v.admin_level == 0 and g.v.any_block_exists(user): return f"{space}@{target}" + if not user: return f"{space}@{target}" return f'{space}@{user.username}' diff --git a/files/routes/awards.py b/files/routes/awards.py index 0f7461759..764eafc45 100644 --- a/files/routes/awards.py +++ b/files/routes/awards.py @@ -600,8 +600,10 @@ def admin_userawards_post(v): note = "" for key, value in notify_awards.items(): - note += f"{value} {AWARDS[key]['title']} {'Awards' if value != 1 else 'Award'}, " + note += f"{value} {AWARDS[key]['title']}, " + if len(note) > 256: return {"error": "You're giving too many awards at the same time!"} + ma=ModAction( kind="grant_awards", user_id=v.id, diff --git a/files/routes/posts.py b/files/routes/posts.py index 74390d92d..6bbdc5e2b 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -15,7 +15,7 @@ from io import BytesIO from files.__main__ import app, limiter, cache, db_session from PIL import Image as PILimage from .front import frontlist, changeloglist -from urllib.parse import ParseResult, urlunparse, urlparse, quote +from urllib.parse import ParseResult, urlunparse, urlparse, quote, unquote from os import path import requests from shutil import copyfile @@ -57,7 +57,7 @@ def publish(pid, v): post.created_utc = int(time.time()) g.db.add(post) - notify_users = NOTIFY_USERS(f'{post.body_html}{post.title}', v) + notify_users = NOTIFY_USERS(post.body_html, v) | NOTIFY_USERS2(post.title, v) cid = notif_comment(f"@{v.username} has mentioned you: [{post.title}]({post.permalink})") for x in notify_users: @@ -526,7 +526,7 @@ def edit_post(pid, v): g.db.add(n) - notify_users = NOTIFY_USERS(f'{body_html}{title}', v) + notify_users = NOTIFY_USERS(body_html, v) | NOTIFY_USERS2(title, v) soup = BeautifulSoup(body_html, features="html.parser") @@ -745,13 +745,14 @@ def submit_post(v): url = urlunparse(new_url) - repost = g.db.query(Submission).filter( - Submission.url.ilike(url), - Submission.deleted_utc == 0, - Submission.is_banned == False - ).one_or_none() + if SITE != 'localhost': + repost = g.db.query(Submission).filter( + Submission.url.ilike(url), + Submission.deleted_utc == 0, + Submission.is_banned == False + ).one_or_none() - if repost: return redirect(repost.permalink) + if repost: return redirect(repost.permalink) domain_obj = get_domain(domain) if domain_obj: @@ -763,6 +764,7 @@ def submit_post(v): try: embed = requests.get("https://publish.twitter.com/oembed", timeout=5, params={"url":url, "omit_script":"t"}).json()["html"] except: embed = None elif url.startswith('https://youtube.com/watch?v='): + url = unquote(url).replace('?t', '&t') yt_id = url.split('https://youtube.com/watch?v=')[1].split('&')[0].split('%')[0] params = parse_qs(urlparse(url).query) t = params.get('t', params.get('start', [0]))[0] @@ -1018,7 +1020,7 @@ def submit_post(v): if not new_post.private: - notify_users = NOTIFY_USERS(f'{body_html}{title}', v) + notify_users = NOTIFY_USERS(body_html, v) | NOTIFY_USERS2(title, v) cid = notif_comment(f"@{v.username} has mentioned you: [{title}]({new_post.permalink})") for x in notify_users: diff --git a/files/routes/static.py b/files/routes/static.py index 9d042672a..57e30f9e3 100644 --- a/files/routes/static.py +++ b/files/routes/static.py @@ -103,10 +103,10 @@ def cached_chart(days): if days > 31: file = "/weekly_chart.png" - day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(30)][1:] + day_cutoffs = [today_cutoff - 86400 * 7 * i for i in range(35)][1:] else: file = "/daily_chart.png" - day_cutoffs = [today_cutoff - 86400 * i for i in range(30)][1:] + day_cutoffs = [today_cutoff - 86400 * i for i in range(35)][1:] day_cutoffs.insert(0, calendar.timegm(now)) diff --git a/files/templates/comments.html b/files/templates/comments.html index e0ec73171..fc639ed1f 100644 --- a/files/templates/comments.html +++ b/files/templates/comments.html @@ -193,7 +193,7 @@ {% endif %} {% if c.bannedfor %} - + {% endif %} {% if c.active_flags %}{{c.active_flags}} Reports{% endif %} {% if c.over_18 %}+18{% endif %} diff --git a/files/templates/submission.html b/files/templates/submission.html index 82d104c62..662e7c365 100644 --- a/files/templates/submission.html +++ b/files/templates/submission.html @@ -329,7 +329,7 @@
{% if p.bannedfor %} - + {% endif %} {% if p.awards %} diff --git a/files/templates/submission_listing.html b/files/templates/submission_listing.html index a916f0455..5880b41b9 100644 --- a/files/templates/submission_listing.html +++ b/files/templates/submission_listing.html @@ -167,7 +167,7 @@
{% if p.bannedfor %} - + {% endif %} {% if p.awards %} diff --git a/snappy_Drama.txt b/snappy_Drama.txt index 42722252b..51311de3e 100644 --- a/snappy_Drama.txt +++ b/snappy_Drama.txt @@ -2794,4 +2794,48 @@ VR, for those who are piling on without actually using it, are probably unaware One time, there was guy directly behind me an my nephews, and he was talking to his kid the whole time. Turned around and told him to STFU it is rude. The guy started giving me shit, saying how he was going to beat the shit out of me after the movie. As the movie ended, I stood up and turned around to see what he was going to do. He and his kid bolted out right away and all I saw was a glimpse of him as he walked quickly out of there. Anyways, I never see a problem with confronting people. You should say something to those people. And if they don't shut up, just grab the baby out of their hands and throw the kid as hard as you can against the screen and start shouting over and over, "See what you made me do!!??" That'll teach them. {[para]} First +{[para]} +Carp bows to Bardfinn. + +In contact with Admin + +Possess woman-like abilities. + +Control Internet with an iron but fair fist. + +Own over 60 subreddits globally. + +Will bankroll the first reddit on Mars (Bardit will be be the first reddit). + +Direct descendants of the ancient royal blood lines. + +Can destroy entire subreddits with a single email. + +Own 99% of DNA editing research facilities on Earth. + +First designer babies will in all likelihood be Bardfinn babies. + +Is said to have 215+ IQ, such intelligence on Earth has only existed deep in Tibetan monasteries & Area 51. + +Ancient Indian scriptures tell of one angels who will descend upon Earth and will bring an era of enlightenment and unprecedented technological progress with them. + +The Tunguska event in 1908 was actually the Bardfinn arriving on planet Earth. How else do you think they got their birthing person last name and how else do you explain the exponential acceleration in technological and scientific development since then? + +They own Nanobot R&D labs around the world. + +You likely have Bardbots inside you right now. + +Bardfinn is in regular communication with Aimee Challenor, forwarding the word of Spez to the average redditor. Who do you think set up the meeting between the wins & the Chapo Traphouse high command (First meeting between the two organisations in over 1000 years) and arranged the Reddit leader’s first trip to Antarctica in history literally a few days later to the Bardfinn bunker in Wilkes land? + +They learned fluent French in under a week. + +Invented post-anabelian froeboid geometrics, a complex field of mathematics which only they can comprehend fully. + +Nation states entrust their gold reserves with them. There’s no gold in Ft. Knox, only Ft. Bardfinn. + +All major philosophers and scientists have made reference to them in one way or another. + +She is about 7 decades old, from the space-time reference point of the base human currently accepted by our society. + +In reality, she is a timeless being existing in all points of time and space from the big bang to the end of the universe. We don’t know her ultimate plans yet. We hope she's a benevolent being. {[para]} \ No newline at end of file