From a80e0f117a0271d428abd939e2896857a8da1b5c Mon Sep 17 00:00:00 2001
From: Andrew Godwin
Date: Mon, 21 Nov 2022 20:25:00 -0700
Subject: Mentionify tests and some fixtures
---
activities/models/post.py | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
(limited to 'activities')
diff --git a/activities/models/post.py b/activities/models/post.py
index 6888b3f..7016077 100644
--- a/activities/models/post.py
+++ b/activities/models/post.py
@@ -167,25 +167,24 @@ class Post(StatorModel):
"""
def replacer(match):
- print(match)
precursor = match.group(1)
handle = match.group(2)
# If the handle has no domain, try to match it with a mention
if "@" not in handle.lstrip("@"):
- identity = self.mentions.filter(username=handle.lstrip("@")).first()
+ username = handle.lstrip("@")
+ identity = self.mentions.filter(username=username).first()
if identity:
url = identity.urls.view
else:
- url = None
+ url = f"/@{username}/"
else:
url = f"/{handle}/"
# If we have a URL, link to it, otherwise don't link
if url:
- return f"{precursor}{handle}"
+ return f'{precursor}{handle}'
else:
return match.group()
- print(f"replacing on {content!r}")
return mark_safe(self.mention_regex.sub(replacer, content))
@property
--
cgit v1.2.3