summaryrefslogtreecommitdiffstats
path: root/activities/models
diff options
context:
space:
mode:
authorAndrew Godwin2022-11-21 20:25:00 -0700
committerAndrew Godwin2022-11-21 20:25:00 -0700
commita80e0f117a0271d428abd939e2896857a8da1b5c (patch)
treeec52ed0a24744207dca44af43a205d7c5f593c55 /activities/models
parent0d1e09fbcdb1a1db93d9561c9323c7ef105e71ca (diff)
downloadtakahe-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.py9
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