From c92c96b498d4e1f477c0395ce9bb14e0bbb87b74 Mon Sep 17 00:00:00 2001 From: Aevann1 Date: Tue, 4 Jan 2022 15:18:37 +0200 Subject: [PATCH] fds --- files/classes/user.py | 5 ----- files/helpers/alerts.py | 4 ++-- files/helpers/markdown.py | 4 ++-- files/routes/users.py | 10 +++++----- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/files/classes/user.py b/files/classes/user.py index 179f62c62..090a17024 100644 --- a/files/classes/user.py +++ b/files/classes/user.py @@ -324,11 +324,6 @@ class User(Base): def url(self): return f"/@{self.username}" - @property - @lazy - def url2(self): - return f"/id/{self.id}" - def __repr__(self): return f"" diff --git a/files/helpers/alerts.py b/files/helpers/alerts.py index 1d3d225e1..418cae630 100644 --- a/files/helpers/alerts.py +++ b/files/helpers/alerts.py @@ -29,7 +29,7 @@ def send_repeatable_notification(uid, text, autojanny=False): for i in re.finditer("

@((\w|-){1,25})", text_html): u = get_user(i.group(1), graceful=True) if u: - text_html = text_html.replace(f'

@{u.username}', f'

@{u.username}') + text_html = text_html.replace(f'

@{u.username}', f'

@{u.username}') existing_comment = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body_html=text_html, created_utc=0).first() @@ -59,7 +59,7 @@ def notif_comment(text, autojanny=False): for i in re.finditer("

@((\w|-){1,25})", text_html): u = get_user(i.group(1), graceful=True) if u: - text_html = text_html.replace(f'

@{u.username}', f'

@{u.username}') + text_html = text_html.replace(f'

@{u.username}', f'

@{u.username}') existing = g.db.query(Comment.id).filter_by(author_id=author_id, parent_submission=None, distinguish_level=6, body_html=text_html, created_utc=0).first() diff --git a/files/helpers/markdown.py b/files/helpers/markdown.py index 7ecb371df..7b5118c9b 100644 --- a/files/helpers/markdown.py +++ b/files/helpers/markdown.py @@ -42,7 +42,7 @@ class CustomRenderer(HTMLRenderer): if not user: return f"{space}@{target}" - return f'''{space}@{user.username}'s profile picture@{user.username}''' + return f'''{space}@{user.username}'s profile picture@{user.username}''' def render_sub_mention(self, token): space = token.target[0] @@ -69,7 +69,7 @@ class Renderer(HTMLRenderer): if not user: return f"{space}@{target}" - return f'{space}@{user.username}' + return f'{space}@{user.username}' def render_sub_mention(self, token): space = token.target[0] diff --git a/files/routes/users.py b/files/routes/users.py index a768804d1..2ae5d1215 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -205,7 +205,7 @@ def suicide(v, username): t = int(time.time()) if v.admin_level == 0 and t - v.suicide_utc < 86400: return {"message": "You're on 1-day cooldown!"} user = get_user(username) - suicide = f"Hi there,\n\nA [concerned user]({v.url2}) 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 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." + suicide = f"Hi there,\n\nA [concerned user](/id/{v.id}) 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 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_repeatable_notification(user.id, suicide) v.suicide_utc = t g.db.add(v) @@ -241,14 +241,14 @@ def transfer_coins(v, username): tax = math.ceil(amount*0.03) tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).one_or_none() tax_receiver.coins += tax - log_message = f"[@{v.username}]({v.url2}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url2})" + log_message = f"[@{v.username}](/id/{v.id}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.id})" send_repeatable_notification(TAX_RECEIVER_ID, log_message) g.db.add(tax_receiver) else: tax = 0 receiver.coins += amount-tax v.coins -= amount - send_repeatable_notification(receiver.id, f"🤑 [@{v.username}]({v.url2}) has gifted you {amount-tax} {app.config['COINS_NAME']}!") + send_repeatable_notification(receiver.id, f"🤑 [@{v.username}](/id/{v.id}) has gifted you {amount-tax} {app.config['COINS_NAME']}!") g.db.add(receiver) g.db.add(v) @@ -277,7 +277,7 @@ def transfer_bux(v, username): receiver.procoins += amount v.procoins -= amount - send_repeatable_notification(receiver.id, f"🤑 [@{v.username}]({v.url2}) has gifted you {amount} marseybux!") + send_repeatable_notification(receiver.id, f"🤑 [@{v.username}](/id/{v.id}) has gifted you {amount} marseybux!") g.db.add(receiver) g.db.add(v) @@ -714,7 +714,7 @@ def u_username_comments(username, v=None): user = get_user(username, v=v) - if username != user.username: return redirect(f'{user.url2}/comments') + if username != user.username: return redirect(f'/id/{user.id}/comments') u = user