diff --git a/docker-compose.yml b/docker-compose.yml index 6c2f0d13f..0f2bcd9bf 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,10 +23,10 @@ services: - PUSHER_KEY=3435tdfsdudebussylmaoxxt43 - IMGUR_KEY=3435tdfsdudebussylmaoxxt43 - SPAM_SIMILARITY_THRESHOLD=0.5 - - SPAM_SIMILAR_COUNT_THRESHOLD=5 - SPAM_URL_SIMILARITY_THRESHOLD=0.1 + - SPAM_SIMILAR_COUNT_THRESHOLD=10 - COMMENT_SPAM_SIMILAR_THRESHOLD=0.5 - - COMMENT_SPAM_COUNT_THRESHOLD=5 + - COMMENT_SPAM_COUNT_THRESHOLD=10 - READ_ONLY=0 - BOT_DISABLE=0 - COINS_NAME=Dramacoins diff --git a/env b/env index c30a997f7..300dfd28a 100644 --- a/env +++ b/env @@ -12,10 +12,10 @@ export YOUTUBE_KEY="3435tdfsdudebussylmaoxxt43" export PUSHER_KEY="3435tdfsdudebussylmaoxxt43" export IMGUR_KEY="3435tdfsdudebussylmaoxxt43" export SPAM_SIMILARITY_THRESHOLD="0.5" -export SPAM_SIMILAR_COUNT_THRESHOLD="5" export SPAM_URL_SIMILARITY_THRESHOLD="0.1" +export SPAM_SIMILAR_COUNT_THRESHOLD="10" export COMMENT_SPAM_SIMILAR_THRESHOLD="0.5" -export COMMENT_SPAM_COUNT_THRESHOLD="5" +export COMMENT_SPAM_COUNT_THRESHOLD="10" export READ_ONLY="0" export BOT_DISABLE="0" export COINS_NAME="Dramacoins" diff --git a/files/__main__.py b/files/__main__.py index f999ea96c..becc3009d 100644 --- a/files/__main__.py +++ b/files/__main__.py @@ -46,10 +46,10 @@ app.config["UserAgent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit app.config["HCAPTCHA_SITEKEY"] = environ.get("HCAPTCHA_SITEKEY","").strip() app.config["HCAPTCHA_SECRET"] = environ.get("HCAPTCHA_SECRET","").strip() app.config["SPAM_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_SIMILARITY_THRESHOLD", 0.5)) -app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] = int(environ.get("SPAM_SIMILAR_COUNT_THRESHOLD", 5)) -app.config["SPAM_URL_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_URL_SIMILARITY_THRESHOLD", 0.5)) +app.config["SPAM_URL_SIMILARITY_THRESHOLD"] = float(environ.get("SPAM_URL_SIMILARITY_THRESHOLD", 0.1)) +app.config["SPAM_SIMILAR_COUNT_THRESHOLD"] = int(environ.get("SPAM_SIMILAR_COUNT_THRESHOLD", 10)) app.config["COMMENT_SPAM_SIMILAR_THRESHOLD"] = float(environ.get("COMMENT_SPAM_SIMILAR_THRESHOLD", 0.5)) -app.config["COMMENT_SPAM_COUNT_THRESHOLD"] = int(environ.get("COMMENT_SPAM_COUNT_THRESHOLD", 0.5)) +app.config["COMMENT_SPAM_COUNT_THRESHOLD"] = int(environ.get("COMMENT_SPAM_COUNT_THRESHOLD", 10)) app.config["READ_ONLY"]=bool(int(environ.get("READ_ONLY", "0"))) app.config["BOT_DISABLE"]=bool(int(environ.get("BOT_DISABLE", False))) app.config["RATELIMIT_KEY_PREFIX"] = "flask_limiting_" diff --git a/files/classes/user.py b/files/classes/user.py index 543956565..607409242 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -227,8 +227,7 @@ class User(Base): @cache.memoize(timeout=86400) def userpagelisting(self, v=None, page=1, sort="new", t="all"): - if self.shadowbanned and not (v and (v.admin_level > 1 or v.id == self.id)): - return [] + if self.shadowbanned and not (v and (v.admin_level > 1 or v.id == self.id)): return [] posts = g.db.query(Submission.id).filter_by(author_id=self.id, is_pinned=False) diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index daa23e901..510dc369d 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -10,7 +10,6 @@ def create_comment(text, autojanny=False): if autojanny: author_id = AUTOJANNY_ID else: author_id = NOTIFICATIONS_ID - text = text.replace('r/', 'r\/').replace('u/', 'u\/') text_html = sanitize(Renderer2().render(mistletoe.Document(text))) new_comment = Comment(author_id=author_id, parent_submission=None, @@ -84,10 +83,16 @@ def send_admin(vid, text): g.db.add(notif) -def NOTIFY_USERS(text, vid): - text = text.lower() +def NOTIFY_USERS(text, v): notify_users = set() for word, id in NOTIFIED_USERS.items(): if id == 0: continue - if word in text and id not in notify_users and vid != id: notify_users.add(id) + if word in text.lower() and id not in notify_users and v.id != id: notify_users.add(id) + + soup = BeautifulSoup(text, features="html.parser") + for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): + username = mention["href"].split("@")[1] + 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.id) + return notify_users \ No newline at end of file diff --git a/files/helpers/const.py b/files/helpers/const.py index 21e3d212e..869197888 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -6,30 +6,30 @@ SITE = environ.get("DOMAIN", '').strip() SITE_NAME = environ.get("SITE_NAME", '').strip() AJ_REPLACEMENTS = { - "you're": '$#3$2', - 'your': "you're", - '$#3$2': 'your', - "too": '$#3$3', - 'to': "too", - '$#3$3': 'to', + " you're ": ' $#3$2 ', + ' your ': " you're ", + ' $#3$2 ': ' your ', + " too ": ' $#3$3 ', + ' to ': " too ", + ' $#3$3 ': ' to ', ' my ': ' their ', ' mine ': ' their ', - "You're": '$#3$2', - 'Your': "You're", - '$#3$2': 'Your', - "Too": '$#3$3', - 'To': "Too", - '$#3$3': 'To', + " You're ": ' $#3$2 ', + ' Your ': " You're ", + ' $#3$2 ': ' Your ', + " Too ": ' $#3$3 ', + ' To ': " Too ", + ' $#3$3 ': ' To ', ' My ': ' Their ', ' Mine ': ' Their ', - "YOU'RE": '$#3$2', - 'YOUR': "YOU'RE", - '$#3$2': 'YOUR', - "TOO": '$#3$3', - 'TO': "TOO", - '$#3$3': 'TO', + " YOU'RE ": ' $#3$2 ', + ' YOUR ': " YOU'RE ", + ' $#3$2 ': ' YOUR ', + " TOO ": ' $#3$3 ', + ' TO ': " TOO ", + ' $#3$3 ': ' TO ', ' MY ': ' THEIR ', ' MINE ': ' THEIR ', } @@ -107,6 +107,24 @@ SLURS = { " elon ": " rocket daddy ", } +single_words = "|".join([slur.lower() for slur in SLURS.keys()]) +SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)") + +def sub_matcher(match: re.Match) -> str: + return SLURS[match.group(0).lower()] + +def censor_slurs(body: str, logged_user) -> str: + if not logged_user or logged_user.slurreplacer: body = SLUR_REGEX.sub(sub_matcher, body) + return body + +def torture_ap(body, username): + body = SLUR_REGEX.sub(sub_matcher, body) + for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) + body = re.sub('(^| )(i|me) ', rf'\1@{username} ', body, flags=re.I) + body = re.sub("(^| )i'm ", rf'\1@{username} is ', body, flags=re.I) + return body + + 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!'] AGENDAPOSTER_MSG = """Hi @{username},\n\nYour comment has been automatically removed because you forgot @@ -205,19 +223,6 @@ else: PUSHER_INSTANCE_ID = '02ddcc80-b8db-42be-9022-44c546b4dce6' PUSHER_KEY = environ.get("PUSHER_KEY", "").strip() -single_words = "|".join([slur.lower() for slur in SLURS.keys()]) -SLUR_REGEX = re.compile(rf"(?i)((?<=\s|>)|^)({single_words})((?=[\s<,.]|s[\s<,.])|$)") - -def sub_matcher(match: re.Match) -> str: - return SLURS[match.group(0).lower()] - -def censor_slurs(body: str, logged_user) -> str: - if not logged_user or logged_user.slurreplacer: body = SLUR_REGEX.sub(sub_matcher, body) - return body - -def censor_slurs2(body: str) -> str: - return SLUR_REGEX.sub(sub_matcher, body) - BADGES = { 1: { 'name': 'Alpha User', @@ -718,5 +723,6 @@ NOTIFIED_USERS = { ' llm ': LLM_ID, 'landlet': LLM_ID, 'dong': DONGER_ID, - 'dong': FARTBINN_ID -} + 'dong': FARTBINN_ID, + 'kippy': KIPPY_ID, +} \ No newline at end of file diff --git a/files/helpers/markdown.py b/files/helpers/markdown.py index 66b4e7208..aead81860 100644 --- a/files/helpers/markdown.py +++ b/files/helpers/markdown.py @@ -3,55 +3,48 @@ from .get import * from mistletoe.span_token import SpanToken from mistletoe.html_renderer import HTMLRenderer import re - from flask import g -# add token/rendering for @username mentions - - class UserMention(SpanToken): pattern = re.compile("(^|\s|\n)@((\w|-){1,25})") parse_inner = False - def __init__(self, match_obj): self.target = (match_obj.group(1), match_obj.group(2)) - + +class UserMention2(SpanToken): + pattern = re.compile("^@((\w|-){1,25})") + parse_inner = False + def __init__(self, match_obj): + self.target = (match_obj.group(1)) + class SubMention(SpanToken): pattern = re.compile("(^|\s|\n)r/(\w{3,25})") parse_inner = False - def __init__(self, match_obj): - self.target = (match_obj.group(1), match_obj.group(2)) class RedditorMention(SpanToken): pattern = re.compile("(^|\s|\n)u/((\w|-){3,25})") parse_inner = False - def __init__(self, match_obj): - self.target = (match_obj.group(1), match_obj.group(2)) class SubMention2(SpanToken): pattern = re.compile("(^|\s|\n)/r/(\w{3,25})") parse_inner = False - def __init__(self, match_obj): - self.target = (match_obj.group(1), match_obj.group(2)) class RedditorMention2(SpanToken): pattern = re.compile("(^|\s|\n)/u/((\w|-){3,25})") parse_inner = False - def __init__(self, match_obj): - self.target = (match_obj.group(1), match_obj.group(2)) class CustomRenderer(HTMLRenderer): @@ -125,27 +118,8 @@ class Renderer(HTMLRenderer): class Renderer2(HTMLRenderer): def __init__(self, **kwargs): - super().__init__(UserMention, - SubMention, - RedditorMention, - SubMention2, - RedditorMention2, - ) - - for i in kwargs: - self.__dict__[i] = kwargs[i] + super().__init__(UserMention2) + for i in kwargs: self.__dict__[i] = kwargs[i] def render_user_mention(self, token): - space = token.target[0] - target = token.target[1] - return f"{space}@{target}" - - def render_sub_mention(self, token): - space = token.target[0] - target = token.target[1] - return f"{space}r/{target}" - - def render_redditor_mention(self, token): - space = token.target[0] - target = token.target[1] - return f"{space}u/{target}" \ No newline at end of file + return f'@{token.target}' \ No newline at end of file diff --git a/files/routes/admin.py b/files/routes/admin.py index 2a9a085d9..a6a190ef6 100644 --- a/files/routes/admin.py +++ b/files/routes/admin.py @@ -151,19 +151,6 @@ def club_ban(v, username): g.db.commit() return {"message": f"@{username} has been kicked from the {cc}. Deserved."} -@app.post("/@/remove_admin") -@limiter.limit("1/second") -@admin_level_required(2) -@validate_formkey -def remove_admin(v, username): - if 'pcm' in request.host or (SITE_NAME == 'Drama' and v.admin_level > 2) or ('rama' not in request.host and 'pcm' not in request.host): - user = get_user(username) - if not user: abort(404) - user.admin_level = 0 - g.db.add(user) - g.db.commit() - return {"message": "Admin removed!"} - @app.post("/@/make_meme_admin") @limiter.limit("1/second") diff --git a/files/routes/comments.py b/files/routes/comments.py index d02efb0b4..e9849bd81 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -206,10 +206,7 @@ def api_comment(v): body += f"\n\n{url}" else: return {"error": f"Image/Video files only"}, 400 - if v.agendaposter and not v.marseyawarded: - for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = body.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ') - body = censor_slurs2(body).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ') + if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username) body_html = sanitize(CustomRenderer().render(mistletoe.Document(body))) @@ -240,7 +237,7 @@ def api_comment(v): is_bot = bool(request.headers.get("Authorization")) - if not is_bot and not v.marseyawarded and 'trans lives matters' not in body.lower(): + if not is_bot and not v.marseyawarded and 'trans lives matters' not in body.lower() and len(body) > 10: now = int(time.time()) cutoff = now - 60 * 60 * 24 @@ -520,24 +517,12 @@ def api_comment(v): if not v.shadowbanned: - notify_users = NOTIFY_USERS(body_html, v.id) + notify_users = NOTIFY_USERS(body_html, 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 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+)")) - - for mention in mentions: - username = mention["href"].split("@")[1] - - user = g.db.query(User).filter_by(username=username).first() - - if user: - if v.any_block_exists(user): continue - if user.id != v.id: notify_users.add(user.id) - for x in notify_users: n = Notification(comment_id=c.id, user_id=x) g.db.add(n) @@ -628,10 +613,7 @@ def edit_comment(cid, v): for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') - if v.agendaposter and not v.marseyawarded: - for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = body.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ') - body = censor_slurs2(body).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ') + if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username) if not c.options: for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body): @@ -798,22 +780,7 @@ def edit_comment(cid, v): g.db.add(c) - notify_users = NOTIFY_USERS(body_html, v.id) - soup = BeautifulSoup(body_html, features="html.parser") - mentions = soup.find_all("a", href=re.compile("^/@(\w+)")) - - if len(mentions) > 0: - for mention in mentions: - username = mention["href"].split("@")[1] - - user = g.db.query(User).filter_by(username=username).first() - - if user: - if v.any_block_exists(user): continue - if user.id != v.id: notify_users.add(user.id) - - - g.db.flush() + notify_users = NOTIFY_USERS(body_html, v) for x in notify_users: notif = g.db.query(Notification).filter_by(comment_id=c.id, user_id=x).first() diff --git a/files/routes/posts.py b/files/routes/posts.py index 97d9e5cbc..f93dcedf6 100644 --- a/files/routes/posts.py +++ b/files/routes/posts.py @@ -58,11 +58,6 @@ def publish(pid, v): g.db.add(post) notify_users = NOTIFY_USERS(f'{post.body_html}{post.title}', v.id) - soup = BeautifulSoup(post.body_html, features="html.parser") - for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): - username = mention["href"].split("@")[1] - 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.id) cid = notif_comment(f"@{v.username} has mentioned you: [{post.title}]({post.permalink})") for x in notify_users: @@ -429,10 +424,7 @@ def edit_post(pid, v): elif len(body) > 140: return {"error":"You have to type less than 140 characters!"}, 403 if title != p.title: - if v.agendaposter and not v.marseyawarded: - for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) - title = title.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ') - title = censor_slurs2(title).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ') + if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username) title_html = filter_emojis_only(title) if v.marseyawarded and len(list(re.finditer('>[^<\s+]|[^>\s+]<', title_html))) > 0: return {"error":"You can only type marseys!"}, 403 @@ -457,10 +449,7 @@ def edit_post(pid, v): for i in re.finditer('^(https:\/\/.*\.(png|jpg|jpeg|gif|webp|PNG|JPG|JPEG|GIF|WEBP|9999))', body, re.MULTILINE): if "wikipedia" not in i.group(1): body = body.replace(i.group(1), f'![]({i.group(1)})') - if v.agendaposter and not v.marseyawarded: - for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = body.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ') - body = censor_slurs2(body).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ') + if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username) if not p.options.count(): for i in re.finditer('\s*\$\$([^\$\n]+)\$\$\s*', body): @@ -561,10 +550,6 @@ def edit_post(pid, v): notify_users = NOTIFY_USERS(f'{body_html}{title}', v.id) soup = BeautifulSoup(body_html, features="html.parser") - for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): - username = mention["href"].split("@")[1] - 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.id) cid = notif_comment(f"@{v.username} has mentioned you: [{p.title}]({p.permalink})") for x in notify_users: @@ -727,10 +712,7 @@ def submit_post(v): url = request.values.get("url", "").strip() - if v.agendaposter and not v.marseyawarded: - for k, l in AJ_REPLACEMENTS.items(): title = title.replace(k, l) - title = title.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ') - title = censor_slurs2(title).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ') + if v.agendaposter and not v.marseyawarded: title = torture_ap(title, v.username) title_html = filter_emojis_only(title) body = request.values.get("body", "").strip() @@ -934,10 +916,7 @@ def submit_post(v): options.append(i.group(1)) body = body.replace(i.group(0), "") - if v.agendaposter and not v.marseyawarded: - for k, l in AJ_REPLACEMENTS.items(): body = body.replace(k, l) - body = body.replace(' I ', f' @{v.username} ').replace(' i ', f' @{v.username} ') - body = censor_slurs2(body).replace(' ME ', f' @{v.username} ').replace(' me ', f' @{v.username} ') + if v.agendaposter and not v.marseyawarded: body = torture_ap(body, v.username) if request.files.get("file2") and request.headers.get("cf-ipcountry") != "T1": file=request.files["file2"] @@ -1058,12 +1037,7 @@ def submit_post(v): if not new_post.private: - notify_users = NOTIFY_USERS(f'{body_html}{title}', v.id) - soup = BeautifulSoup(body_html, features="html.parser") - for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): - username = mention["href"].split("@")[1] - 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.id) + notify_users = NOTIFY_USERS(f'{body_html}{title}', v) cid = notif_comment(f"@{v.username} has mentioned you: [{title}]({new_post.permalink})") for x in notify_users: @@ -1338,7 +1312,9 @@ def api_pin_post(post_id, v): if v.id != post.author_id: return {"error": "Only the post author's can do that!"} post.is_pinned = not post.is_pinned g.db.add(post) - g.db.commit() + cache.delete_memoized(User.userpagelisting) + + g.db.commit() if post.is_pinned: return {"message": "Post pinned!"} - else: return {"message": "Post unpinned!"} + else: return {"message": "Post unpinned!"} \ No newline at end of file diff --git a/files/routes/settings.py b/files/routes/settings.py index 37854a9b8..bbed85d0a 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -217,12 +217,7 @@ def settings_profile_post(v): error="Your friends list is too long") - notify_users = NOTIFY_USERS(friends_html, v.id) - soup = BeautifulSoup(friends_html, features="html.parser") - for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): - username = mention["href"].split("@")[1] - 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.id) + notify_users = NOTIFY_USERS(friends_html, v) cid = notif_comment(f"@{v.username} has added you to their friends list!") @@ -264,12 +259,7 @@ def settings_profile_post(v): error="Your enemies list is too long") - notify_users = NOTIFY_USERS(enemies_html, v.id) - soup = BeautifulSoup(enemies_html, features="html.parser") - for mention in soup.find_all("a", href=re.compile("^/@(\w+)")): - username = mention["href"].split("@")[1] - 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.id) + notify_users = NOTIFY_USERS(enemies_html, v) cid = notif_comment(f"@{v.username} has added you to their enemies list!") diff --git a/files/templates/gif_modal.html b/files/templates/gif_modal.html index 2d32e1f99..efa4bc097 100644 --- a/files/templates/gif_modal.html +++ b/files/templates/gif_modal.html @@ -1,5 +1,5 @@