diff options
Diffstat (limited to 'activities/models')
-rw-r--r-- | activities/models/post.py | 9 |
1 files changed, 4 insertions, 5 deletions
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}<a href='{url}'>{handle}</a>" + return f'{precursor}<a href="{url}">{handle}</a>' else: return match.group() - print(f"replacing on {content!r}") return mark_safe(self.mention_regex.sub(replacer, content)) @property |