diff options
author | Andrew Godwin | 2022-11-21 20:25:00 -0700 |
---|---|---|
committer | Andrew Godwin | 2022-11-21 20:25:00 -0700 |
commit | a80e0f117a0271d428abd939e2896857a8da1b5c (patch) | |
tree | ec52ed0a24744207dca44af43a205d7c5f593c55 /activities/models | |
parent | 0d1e09fbcdb1a1db93d9561c9323c7ef105e71ca (diff) | |
download | takahe-a80e0f117a0271d428abd939e2896857a8da1b5c.tar.gz takahe-a80e0f117a0271d428abd939e2896857a8da1b5c.tar.bz2 takahe-a80e0f117a0271d428abd939e2896857a8da1b5c.zip |
Mentionify tests and some fixtures
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 |